Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Vs2008 Linq

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Linq Tech Days08 Lux
Linq Tech Days08 Lux
Chargement dans…3
×

Consultez-les par la suite

1 sur 47 Publicité

Plus De Contenu Connexe

Diaporamas pour vous (20)

Les utilisateurs ont également aimé (20)

Publicité

Similaire à Vs2008 Linq (20)

Plus par Gregory Renard (20)

Publicité

Plus récents (20)

Vs2008 Linq

  1. 1. LINQ<br />Des nouveautés de C#3/VB9 à LINQ et perspectives<br />
  2. 2. A propos<br />… de votre speaker : Gregory Renard [akaRedo]<br /><ul><li> CTO Wygwam, www.wygwam.com
  3. 3. Bureau d’étude et d’aide à l’acquisition des technologies
  4. 4. Microsoft RegionalDirector / MVP
  5. 5. Auteur (2006 – 2007)
  6. 6. Livres/Livres Blancs : .NET 2.0 /3.0/3.5– C#/VB – VS2005/VS2008
  7. 7. Articles/Dossiers Techniques presse francophone
  8. 8. Communautaire
  9. 9. Blog : http://blogs.developpeur.org/redo
  10. 10. Sites : Codes-Sources, ASP-PHP.NET, TechHeadBrothers, MSDN, …
  11. 11. Speaker Microsoft .NET > 6 ans
  12. 12. Events MSDN Belgique – Luxembourg
  13. 13. Events MSDN France
  14. 14. TechDaysFrance, BeLux, Suisse
  15. 15. Wygday
  16. 16. E-mail : gregory@wygwam.com</li></li></ul><li>Roadmap<br />Des nouveautés de C#3/VB9 à LINQ et perspectives<br /><ul><li>Rappel :
  17. 17. .NET Fx, C# 2.0 (VB 8.0)
  18. 18. Nouveautés des langages
  19. 19. C# v3.0 (VB v9.0)
  20. 20. LINQ
  21. 21. Overview
  22. 22. Perspectives</li></li></ul><li>Rappel<br />Vue d’ensemble des évolutions du .NETFx, des langages et de son IDE<br />
  23. 23. De 2002 à 2008<br />Source : http://www.danielmoth.com/Blog/2007/06/visual-studio-2008-stack.html<br />
  24. 24. De 2002 à 2008<br />
  25. 25. .NET Framework 3.5 SP1<br />ADO.NET Entity Framework<br />ADO.NET Data <br />Services<br />ASP.NET Dynamic Data<br />WPF & WCF Enhancements<br />.NET Framework 3.5<br />Framework<br />LINQ<br />WCFFEnhancements<br />Additional Enhancements<br />.NET Framework 3.0 + SP2<br />WPF<br />WCF<br />WF<br />Windows CardSpace<br />.NET Framework 2.0 + SP2<br />
  26. 26. .NET Framework & Tools Roadmap<br />.NET Framework 3.0<br />.NET Framework 3.5<br />.NET <br />Releases<br />3.5 SP1<br />Silverlight 2<br />.NET 4<br />ASP.NET MVC<br />Visual Studio 2008<br />ASP.NET AJAX 1.0<br />Silverlight 1.0<br />Tools Releases<br />VS 2008 SP1<br />VS Tools for SL<br /><ul><li> VS 2005 Ext. for WF
  27. 27. VS 2005 Ext. for WCF/WPF CTP</li></ul> VS “10”<br />Later..<br />2007<br />2008<br />2006<br />
  28. 28. Qu’est-ce qui est cool dans.NET 3.5??<br />Linq<br />Linq to objects<br />Linq to xml<br />Linq to Sql<br />Linq to dataset<br />LinqLinqDataSource in ASP.NET<br />Linq support in WPF databinding<br />Linq<br />Linq, Linq, …<br />
  29. 29. Qu’est-ce qui est cool dans .NET 3.5??<br />Web applications<br />ASP.NET AJAX built in<br />Application Services Exposed<br />ListView control<br />Service Applications<br />Syndication object model<br />WCF support for REST and JSON services<br />WCF & WF integration<br />Client Application<br />Excellent tooling support!<br />UIElement3D <br />Managed Add-in framework (System.AddIn)<br />XBAP support for Firefox<br />
  30. 30. Nouveautés des langages<br />Vue d’ensemble des évolutions de C# 3.0 / VB 9.0<br /><ul><li> Vue d’ensemble des nouveautés
  31. 31. C# v3.0
  32. 32. VB v9.0</li></li></ul><li>C#, son Historique !<br />
  33. 33. C# 3.0, ses objectifs de conception !<br />Intégration d’objets, des données relationnelles et du XML<br />LINQ<br />Enrichissement du langage (C# v1.0, v2.0)<br />Basésur la .NET CLR 2.0 <br />Ajout de nouvellesfonctionnalités<br />Lambda expressions<br />Détachement du langage des APIs spécifiques<br />100% compatible avec les versions précédentes<br />C# 3.0 peutêtrecomplètementtraduit en C# 2.0<br />
  34. 34. C# 3.0, ses Innovations !<br />Query expressions<br />var contacts =<br /> from c in customers<br /> where c.State == &quot;WA&quot;<br /> select new { c.Name, c.Phone };<br />Expression trees<br />Local variable type inference<br />Automatic properties<br />Lambda expressions<br />var contacts =<br /> customers<br /> .Where(c =&gt; c.State == &quot;WA&quot;)<br /> .Select(c =&gt; new { c.Name, c.Phone });<br />Partial methods<br />Extension methods<br />Object initializers<br />Anonymous types<br />
  35. 35. VB, son Historique !<br />
  36. 36. VB 9.0, ses objectifs de conception !<br />Intégration d’objets, des données relationnelles et du XML<br />LINQ + Intégration XML<br />Amelioration du langage<br />Amélioration de la syntaxe des tâches typiques<br />Ajout de nouvellesfonctionnalités<br />Lambda expressions<br />
  37. 37. VB 9.0, ses Innovations !<br />Query expressions<br />Dim contacts =<br />From c In customers<br />Where c.State= &quot;WA&quot;<br />Select New With { Name = c.Name, _ Phone = c.Phone }<br />Expression trees<br />Implicitly typed local variable<br />Deep XML support<br />Lambda expressions<br />Dim contacts =<br />customers _<br /> .Where(Function(c) c.State = &quot;WA&quot;) _<br /> .Select(Function(c) New With { Name = c.Name, _ Phone = c.Phone })<br />Partial methods<br />Extension methods<br />Anonymous types<br />Object initializers<br />
  38. 38. De C# 3.0 / VB 9.0 à LINQ<br />… en route vers LINQ !!!<br /><ul><li>Rappel C# v2.0 (VB v8.0)
  39. 39. Le pourquoi des nouveautés
  40. 40. C# v3.0 (VB v9.0)
  41. 41. Des nouveautés à LINQ … 1 pas ?</li></li></ul><li>Rappel C# v2.0 – VB v8.0<br />http://msdn2.microsoft.com/en-us/library/7cz8t42e(VS.80).aspx<br />
  42. 42. Rappel C#2.0 / VB 8.0<br />Types Génériques (C#/VB)<br />Classes partielles (C#/VB)<br />Méthodes Anonymes (C#)<br />Itérateurs (C#)<br />Qualificateur global de Namespace (C#)<br />Classes Statiques (C#)<br />Types Nullables (C#)<br />…<br />
  43. 43. Types Generiques (C# - VB)<br />Suppression du boxing/unboxing<br />Suppression du Casting implicite<br />Gestion de l’erreur lors de la compilation<br />Meilleure lisibilité du code<br />Meilleures performances<br />
  44. 44. Classes partielles (C# - VB)<br />Définition d’une classe sur plusieurs fichiers<br />Utilité dans la génération de code<br />Exploité par les Winforms et Webforms<br />
  45. 45. Méthodes anonymes (C#)<br />Manière de passer un bloc de code comme paramètre de délégué.<br />Réduction du codage dans l’instanciation de délégués en éliminant la nécessité de créer une méthode séparée<br />
  46. 46. Méthodes anonymes (C#)<br />public delegate T Func&lt;T, A&gt; (A a)<br />Délégué générique qui représente une fonction à un paramètre<br />
  47. 47. Itérateurs (C#)<br />Méthode, accesseur ou opérateur get permettant de prendre en charge l&apos;itération foreach dans une classe ou une struct sans implémenter l&apos;interface IEnumerable dans son intégralité<br />Exécution différée<br />Mot clé yield return<br />
  48. 48. Qualificateur global de Namespace (C#)<br />« :: »<br />Résout le membre être caché par une autre entité du même nom. <br />
  49. 49. Classes Statiques (C#)<br />Accès sans création d’instances<br />Chargé automatiquement par le CLR<br />
  50. 50. Types Nullables (C#)<br />Permet d’avoir des types valeurs nullables<br />Pratique pour les données nullables provenant de bases de données<br />
  51. 51. Nouveautés : C# v3.0 / VB 9.0 ?<br />http://msdn2.microsoft.com/en-us/library/bb383815(VS.90).aspx<br />
  52. 52. Types implicites / Inférence de types<br />« Var »<br />Déclaration de variable ou Array sans spécifier de type<br />Déclaration fortement typée<br />Doit être directement initialisée<br />Variables locales uniquement<br />
  53. 53. Initialisation d’objets simplifiée<br />Déclaration avec unesyntaxesimplifiée.<br />Initialisationd’objettypé<br /> Person p = new Person {Name = &quot;Chris Smith&quot;, Age = 31}; <br />Initialisationd’objet avec type anonyme<br />varproductInfos = from p in products select new {p.ProductName, p.UnitPrice};<br />foreach(var p in productInfos){...}<br />Initialisation d’objet avec un type nullable : compile time error !<br />
  54. 54. … Initialisation de collections simplifiée<br />Uniquement pour les collection de classes implementant “IEnumerable”<br /> List&lt;int&gt; digits = new List&lt;int&gt; { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };<br /> List&lt;Test&gt; list = new List&lt;Test&gt; <br /> { <br /> new Test{ num = 1, s = &quot;Hello&quot;}, <br /> new Test{ num = 2, s = &quot;World&quot;}, <br /> new Test{ num = 3, s = &quot;From C#&quot;} <br /> };<br />
  55. 55. … Propriétés automatiques<br />Déclaration avec unesyntaxesimplifiée.<br />Attributs non permis (utiliseralors la méthoderégulière) <br />
  56. 56. Types anonymes<br />Types automatiquement générés à la compilationvar v = new { Amount = 108, Message = &quot;Hello&quot; };<br />Non disponible dans le code source<br />Intellisence disponible<br />Typiquementutilisédans la clause select des query expression<br />Repose surl’initialisationd’objet et collections<br /> var query = fromprod in Products select new { prod.Color, prod.Price}; foreach(var v in query) { Console.WriteLine(&quot;Color={0}, Price={1}&quot;, v.Color, v.Price); }<br />
  57. 57. Méthodes d’extension <br />Ajout “Virtuel” d’une méthode à un type<br />Méthode Static : premier paramètre “this”<br />Étend, ne modifie pas le type, override <br />Définition du scope par “using namespaces”<br />
  58. 58. Expressions Lambda<br />Ecriture inline de méthodes<br />Lambda opérateur « =&gt; »<br />Simplifications d&apos;écriture des entêtes d&apos;une méthode anonyme<br />delegateint D1(int i); D1 myDelegate1 = x =&gt; x + 1; int j = myDelegate1(5); //j = 6<br />Permet d’écrire une fonction dans une expression et de récupérer un pointeur vers la fonction<br />Possibilité de récupérer un arbre d’expression<br />
  59. 59. Expressions Lambda<br />Exemplesd’expressions lambda<br /> x =&gt; x + 1 // Implicitly typed, expression body<br /> x =&gt; { return x + 1; } // Implicitly typed, statement body<br /> (int x) =&gt; x + 1 // Explicitly typed, expression body<br /> (int x) =&gt; { return x + 1; } // Explicitly typed, statement body<br /> (x, y) =&gt; x * y // Multiple parameters<br /> () =&gt; Console.WriteLine() // No parameters<br />
  60. 60. Expressions Lambda<br />Inférence de type dans une Lambda<br />customers.Where(c =&gt; c.City == &quot;London&quot;);<br />Opérateurs de vérification<br />Func&lt;int, bool&gt; myFunc = x =&gt; x == 5; <br />bool result = myFunc(4); // returns false of course<br />int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; intoddNumbers = numbers.Count(n =&gt; n % 2 == 1);<br />Ne pas confondre avec l’opérateur “&gt;=“<br />varfirstSmallNumbers = numbers.TakeWhile((n, index) =&gt; n &gt;= index);<br />
  61. 61. Arbres d’expression<br />usingSystem.Linq.Expressions;Expression&lt;Func&lt;int, bool&gt;&gt; exprTree = num =&gt; num &lt; 5; <br />Les expressions lambda peuvent être traduite <br />Code IL<br />Arbre d’expressions<br />Peuvent être parsés au Runtime<br />Utilisés au sein des LinqQuery Provider (Linq to SQL)<br />Func&lt;int,int&gt; square = i =&gt; i * i;int four = square(2);Expression&lt;Func&lt;int,int&gt;&gt; squareEx = i =&gt; i * i;<br />λ<br />*<br />i<br />i<br />i<br />
  62. 62. Expressions<br />Une expression représente l’arbre d’objets qui représente l’expression passée en argument<br />
  63. 63. Méthodes Partielles<br />Les types partiels peuvent maintenant contenir des méthodes partielles<br /> partial class Customer { partial void OnCreated() {Console.WriteLine(“Welcome new customer”); } }<br />
  64. 64. VB v9.0<br />http://msdn2.microsoft.com/en-us/library/y17w47af(VS.90).aspx<br />
  65. 65. Types nullables<br />Valid for all value types<br />Dim a As Integer?‘Will be Nothing<br />a = 123<br />a = Nothing‘Boolean HasValue property<br />Dim hasValue = a.HasValue‘Get the value via Value property or directly<br />Dim value1 As Integer = a.Value<br />Dim value2 As Integer = a<br />Will throw exception if equal to Nothing<br />
  66. 66. Types implicites<br />« Dim »<br />Déclaration de variable ou Array sans spécifier de type<br />Déclaration fortement typée<br />Doit être directement initialisée<br />Variables locales uniquement<br />
  67. 67. Initialisation d’objets<br />Déclaration avec unesyntaxesimplifiée<br />Mot clé “With”<br />Initialisationd’objettypé<br /> Dim namedCust = New Customer With {.Name = “xxx&quot;}<br />Initialisationd’objet avec type anonyme<br /> Dim anonymousCust = New With {.Name = “xxx&quot;}<br />Initialisation d’objet avec un type nullable : compile time error !<br />
  68. 68. Types anonymes<br />Types automatiquement générés à la compilation Dim product1 = New With {.Name = &quot;paperclips&quot;, .Price = 1.29}<br />Non disponible dans le code source<br />Intellisence disponible<br />Typiquementutilisédans la clause select des query expression<br />Repose surl’initialisationd’objet<br />
  69. 69. Types anonymes : Key Properties<br />Comparaison de deux types anonymes (Key)<br />Que les « Key » sont comparées<br />Les valeurs des « Key » sont :<br />Read-Only<br />Ne peuvent être changées<br />Seule la valeur d&apos;une propriété « Key » est incluse dans l&apos;algorithme compilateur produisant le code du type anonyme.<br />
  70. 70. RelaxedDelegates<br />Vraie relaxation : les paramètres ne sont pas employés, vous pouvez ne pas les utiliser.<br /> Dim WithEventsbtn As New Button()<br />SubBOnClick(ByValsender As Object, ByVal e As EventArgs) Handlesbtn.Click<br />MessageBox.Show(&quot;Hello World from&quot; & btn.Text)<br /> End Sub<br />SubRelaxedOnClick() Handlesbtn.Click<br />MessageBox.Show(&quot;Hello World from&quot; & btn.Text)<br /> End Sub<br />
  71. 71. Méthodes d’extension <br />Ajout “Virtuel” d’une méthode à un type<br />Extension attribute &lt;Extension()&gt; de l’espace de nom System.Runtime.CompilerServices<br />Étend, ne modifie pas le type, override <br />Définition du scope par “imports namespaces”<br />
  72. 72. Expressions Lambda<br />Ecriture inline de méthodes<br /> Dim fnums = numbers.Where(Function(n) n &lt; 5)<br />Lambda opérateur « Function »<br />Simplifications d&apos;écriture des entêtes d&apos;une méthode anonyme<br />Permet d’écrire une fonction dans une expression et de récupérer un pointeur vers la fonction<br />Possibilité de récupérer un arbre d’expression<br />
  73. 73. Meilleur support XML<br />Modèle hiérarchique de programmation simplifié<br />Imports &lt;xmlns:ns=“http://myNamespace/schema”&gt;Dim books = &lt;books&gt; &lt;book Title=“Welcome to VB 9.0”&gt; &lt;author Name=“Bart”&gt; &lt;origin&gt;Belgium&lt;/origin&gt; &lt;/author&gt; &lt;/book&gt; &lt;/books&gt;For Each book in books.&lt;book&gt;<br /> Console.WriteLine(book.@Title); Console.WriteLine(book.&lt;author&gt;.@Name); Console.WriteLine(book...&lt;origin&gt;);<br />Next<br />Inline XML<br />Child axis .&lt; (for iteration)<br />Attribute axis (.@)<br />Descendant axis …search in all descendants<br />
  74. 74. Meilleur support xml<br />LINQ query<br />DimcountriesWithCapital = _&lt;Countries&gt;&lt;%=From country In Countries, city In Capitals _ Wherecountry.Name = city.Country _Select _&lt;CountryName=&lt;%=country.Name%&gt;Density=&lt;%=country.Population / country.Area%&gt;&gt;&lt;Capital&gt;&lt;Name&gt;&lt;%=city.Name%&gt;&lt;/Name&gt;&lt;Longitude&gt;&lt;%=city.Longitude%&gt;&lt;/Longitude&gt;&lt;Latitude&gt;&lt;%=city.Latitude%&gt;&lt;/Latitude&gt;&lt;/Capital&gt;&lt;/Country&gt; _%&gt;&lt;/Countries&gt;<br />ASP-alike embedded expressions<br />
  75. 75. Autres amélioration VB v 9.0<br />Friend assemblies<br />InternalsVisibleTo attribute recognized<br />Runtime agility<br />Compile without Microsoft.VisualBasic.dll<br />Need originates from CF and Silverlight<br />New /vbruntime switch<br />Improved generic type inferencing<br />Calling Object members on interfaces<br />
  76. 76. Et là … « LINQ » !<br />Des nouveauté s à LINQ (.NET Language-IntegratedQuery) : un pas ?<br />http://msdn2.microsoft.com/fr-fr/netframework/aa904594.aspx<br />
  77. 77. LINQ : Définition<br />Linq = LanguageINtegratedQuery<br />Exemples<br />DLinq = Database + Linq<br />Appelé maintenant Linq to Data<br />Xlinq = XML + Linq<br />Appelé maintenant Linq to XML<br />
  78. 78. LINQ : Concepts<br />Linq = <br />innovation de VS2008 et .NET 3.5<br />Change radicalement le travail de données<br />Avantages<br />Simplifie l’écriture des requêtes<br />Unifie la syntaxe de requêtes pour tout type de source de données<br />Renforce la connection entre les données relationnelles et le monde de l’OO<br />Accélère les développements <br />Gestion des erreurs à la compilation<br />Intellisense et debugging<br />
  79. 79. LINQ : Fondations C# v3.0 – VB v9.0<br />Query expressions<br />var contacts =<br /> from c in customers<br /> where c.State == &quot;WA&quot;<br /> select new { c.Name, c.Phone };<br />Expression trees<br />Local variable type inference<br />Automatic properties<br />Lambda expressions<br />var contacts =<br /> customers<br /> .Where(c =&gt; c.State == &quot;WA&quot;)<br /> .Select(c =&gt; new { c.Name, c.Phone });<br />Partial methods<br />Extension methods<br />Object initializers<br />Anonymous types<br />
  80. 80. LINQ : Architecture<br />Others…<br />VB<br />C#<br />.NET Language Integrated Query (LINQ)<br />Sources de données LINQ<br />Linqsur des sources ADO.NET<br />LINQ <br />To XML<br />LINQ <br />To Entities<br />LINQ <br />To SQL<br />LINQ <br />To Datasets<br />LINQ <br />To Objects<br />Provider<br />&lt;book&gt;<br /> &lt;title/&gt;<br /> &lt;author/&gt;<br /> &lt;price/&gt;<br />&lt;/book&gt;<br />XML<br />Relationnel<br />Objets<br />
  81. 81. Une syntaxe unique pour plusieurs sources de données<br />
  82. 82. LINQ : 3 parties de toute requête<br />Touterequête LINQ consiste en 3 actions essentielles :<br />Obtention de la source de données(xml, db, Objects)<br />Création de la requête<br />Exécution de la requête<br />
  83. 83. LINQ : Framework<br />L’architecture à la base de Linq est constituée de deux parties<br />LINQ Language Extensions Un langage de programmation implémentant les extensions de langage LINQ<br />C# et VB implémentés au sein de VS2008<br />LINQ Providers Provider LINQ implémentant les Standard QueryOperator méthodes pour chaque source de données spéficique.<br />
  84. 84. LINQ : Requête de base<br />IEnumerable&lt;Customer&gt; customerQuery = from cust in customers //...<br />Exemple : <br />List&lt;int&gt; numberList = new List&lt;int&gt; { 1, 2, 3, 4 };var query = from i in numberList<br /> where i &lt; 4<br /> select i;<br />
  85. 85. Query Expressions<br />   var locals = from c in customers<br />Wherec.ZipCode==91822<br /> select (new {FullName=c.FirstName + “ “ + c.LastName, HomeAdresse=c.Address});<br /><br />var locals = customers .Where(c =&gt; c.ZipCode == 91822) .Select(c =&gt; new { FullName = c.FirstName + “ “ + c.LastName, HomeAddress = c.Address }); <br />
  86. 86. Linq or not : Différence ?<br />C#2<br />List&lt;City&gt; returnCities = new List&lt;City&gt;();<br />Foreach (city c in cities)<br />{<br />If (c.Name==« London »)<br />returnCities.Add(c);<br />}<br />C#3<br />var query= from c in cities<br />Where c. Name==« London »<br />Select c;<br />
  87. 87. Exprimer la sémantique d’une requête et non son implémentation<br />
  88. 88. LINQ : Projections - SELECT<br />Utilisation du Keyword “Select”<br />Nécessité de modifier, transformer les donnéesretournées par unerequête LINQ<br />LINQ permet des scénariosavancés de mise en forme de données = “Projections”<br />Exploitation des type anonymesproposés par le compilateur<br />
  89. 89. LINQ : Projections + Types Anonymes<br /> List&lt;City&gt; cities = CityUtilityHelper.GetCities();<br />var places = from city in cities<br /> where city.DistanceFromSeattle &gt; 1000<br />select new {<br /> City = city.Name,<br /> Country = city.Country,<br />DistanceInKm = city.DistanceFromSeattle * 1.61<br /> };<br /> GridView1.DataSource = places;<br /> GridView1.DataBind();<br />Type anonymeutilisé pour forger un type de retour personnalisé ! Application d’une conversion Miles/Kms<br />
  90. 90. LINQ : Query Operators<br />C# 3.0<br />VB 9.0<br />from .. in ..<br />where ..<br />select .. [into ..]<br />group .. by .. [into ..]<br />orderby .. [descending]<br />join .. in .. on .. equals ..<br />let .. = ..<br />From .. [As ..] In ..<br />Where ..<br />Select .. [,..]*<br />Group .. By .. Into ..<br />Group Join .. [As ..] In .. On ..Equals .. [...] Into ..<br />Order By ... [Descending]<br />Join .. In .. On ..Equals .. [...]<br />Let .. = ...<br />Others:<br />Skip, Skip While, Take, Take While<br />Aggregates: All, Any, Average, [Long]Count, Max, Min, Sum<br />Les opérateurs sont implémentés via des méthodes d’extensions<br />
  91. 91. Vos questions …<br />
  92. 92. Conclusions<br />Vue d’ensemble des évolutions du .NETFx et de son IDE<br /><ul><li>Nouveautés de C# v3.0 / VB 9.0
  93. 93. Des nouveautés à LINQ : un pas ?
  94. 94. LINQ : .NET Language-IntegratedQuery</li></ul>… Vos Questions ?<br />

Notes de l'éditeur

  • • VB9• C#3• IDE enhancements for .NET Fx 3.0• .NET Fx 3.5• Impact of Windows Server 2008 for developers
  • The main points are that the CLR engine is the same version (so no need to retest your apps) and that the headline feature is the language enhancements (C#3 & VB9 compilers) and LINQ.
  • The main points are that the CLR engine is the same version (so no need to retest your apps) and that the headline feature is the language enhancements (C#3 & VB9 compilers) and LINQ.
  • Time: 4 minDiscussion Points:How do the new 3.5 SP1 technologies relate to previous versions of the framework?First, let’s talk about how these new SP1 enhancements relate to the 3.5, 3.0, and 2.0 versions of the framework.The .NET Framework 3.5 SP1 will add these technologies on top of the framework 3.5 that just shipped in November.In addition, the current plan of record is that there will be updated service packs for both the 3.0 assemblies and the 2.0 framework and CLRSo to be clear, the .NET Framework 3.5 SP1 will depend on the .NET Framework 3.5, 3.0 with SP2, and 2.0 with SP2 to be installed on a users machine.
  • C# - started as “the (first) language for CLR”; emphasize the pragmatic approach (cf. Anders Hejlsberg) = be explicit about language features like properties, events, etc.  developer confidence2.0 = generics wave (impact on CLR) + additional useful things (that do require generics on their own + that are useful on their own)3.0 = LINQ + making the language more concise, more productive, more powerful, ...
  • LINQ: tell the story of Reflex 2.0, Dbase III+, ... where data and code were close together  structured + distributed programming changed this = layered approach  result: data and code on two islands with a huge gap between the two  need for O/R mapping tools etcWith LINQ: data becomes a first-class citizen of the languageReduce “language noise” (e.g. tiresome repetitive code etc)API independent  you can reimplement stuff on your own, the language doesn’t care about it (e.g. extension methods on Ienumerable<T>, don’t mention the word yet)Backward compat: refer to MSR paper on formal proof of the possibility for translation of every C# 3.0 program to an equivalent C# 2.0 program (semantically)
  • Build up the slide and introduce “syntactical sugar”. Story telling approach referring back to the gap between data and code and the LINQ solution using Language Integrated queries  requires glue: functional style programming concepts, introduction of concepts from the relational world (e.g. projection clauses require anonymous types) and language simplification (e.g. object initializers).Use the words:-Different compilation stages (front-end query syntax is translated into “pure” C# into ..., e.g. resolution of query expressions to chains of method calls)-Method call chain (can still be instance methods or extension methods)
  • VB = longer history (up to 9.0)Refer to huge transition from 6.0 to .NET which implied the creation of a runtime library for bw compat: play the rules of the CLS (OO for example) and remain consistent with VB pre-.NETVB 8.0 = GenericsVB 9.0 = LINQ + XML (difference with C#)
  • Similar story as in C# 3.0 except for XML integration; emphasize that language evolutuon doesn’t mean that languages have to go hand in hand on any field.
  • Similar story as with C# 3.0 but abbrev’d.
  • http://msdn2.microsoft.com/fr-fr/library/7cz8t42e(VS.80).aspx
  • Réf : http://www.dotnetguru.org/articles/dossiers/generics/CS2_Generics_FR2.htm
  • Réf : http://www.dotnetguru.org/articles/dossiers/anonymescsharp2/CS2_AnonymousMethod_FR.htmThe delegate keyword is used to declare a reference type that can be used to encapsulate a named or an anonymous method. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure. For applications of delegates, see Delegates and Generic Delegates.
  • http://msdn2.microsoft.com/en-us/library/sx2bwtw7(VS.80).aspx
  • Traitement continuPossibilité de gérer des listes infinies comme dans les langages fonctionnels
  • http://msdn2.microsoft.com/fr-fr/library/79b3xss3(VS.80).aspx
  • http://msdn2.microsoft.com/en-us/library/bb383815(VS.90).aspx
  • When used with local variables, the var keyword instructs the compiler to infer the type of the variable or the array elements from the expression on the right side of the initialization statement.Indispensable pour les types anonymeshttp://msdn2.microsoft.com/fr-fr/library/bb384061(VS.90).aspx
  • http://msdn2.microsoft.com/fr-fr/library/bb384062(VS.90).aspx
  • Collection initializers provide a way to specify one or more object intializers when initializing any collection class that implements IEnumerable. By using a collection initializer you do not have to specify multiple calls to the Add method of the class in your source code; the compiler adds the calls2ème exemple :The following collection initializer uses object initializers to initialize objects of the Test class defined in an earlier example. Note that the individual object initializers are enclosed in braces and separated by commas.

×