SQL Saturday 28 - .NET Fundamentals

1,127 views

Published on

This is from my presentation @ 7:30 AM on August 14th at SQL Saturday 28 in Baton Rouge, LA.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,127
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
51
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • That big question mark is editable – use whatever character you want!
  • SQL Saturday 28 - .NET Fundamentals

    1. 1. #28 Baton ROuge<br />.NET Fundamentals<br />Mike Huguet<br />
    2. 2. Solutions Architect for<br />BRDNUG leader, http://brdnug.org <br />MS Patterns & Practices SP Guidance Advisor<br />SQLSat28 Organizer<br />http://twitter.com/mhuguet <br />http://geekswithblogs.com/mikehuguet<br />Mike Huguet<br />
    3. 3. A.K.A – “Huggy” Bear<br />What does he do anyway?<br />Favorite restaurant is any $5 Chinese Buffet<br />He only quotes movies from the 80’s<br />Alternate Intro<br />
    4. 4. Introduce some of the “new” fundamentals<br />Enhance knowledge of these fundamentals<br />Objectives<br />Face.Expression!=<br />
    5. 5. Feature Timeline<br />2.0<br />3.0<br />3.5<br />4.0<br />3.5 SP1<br />2005<br />2006<br />2007<br />2010<br />2008<br />Generics<br /><ul><li>Extensions
    6. 6. Lambdas
    7. 7. LINQ</li></li></ul><li>Language specific implementation / syntax<br />Compiler and IDE magic<br />Increase productivity and readability / reduce code<br />What’s in Common<br />
    8. 8. ?<br />Generics<br />“Generics let you tailor a method, class, structure, or interface to the precise data type it acts upon.”<br />- MSDN<br />
    9. 9. Generics<br />- MSDN<br />
    10. 10. Native to the CLR<br />Allow for better type safety increasing performance (no box, unbox, casting)<br />ArrayList vs. List<T><br />IDE Magic<br />What are Generics?<br />
    11. 11. *200% perf gain value types (i.e.-string, int…)<br />*100% perf gain ref types (i.e.-MyClass)<br />Used throughout .NET<br />Make great containers<br />i.e.-List<T><br />Activator.CreateInstance<T>()<br />Uses / Benefits<br />* - #’s from MSDN<br />
    12. 12. C#<br />List<string> x = new List<string>();<br />String GetValueAsString<T>(T entity) {}<br />VB.NET<br />Dim x As New List(Of String)<br />Function GetValueAsString(of T)(ByRef entity As T) As String<br />Syntax<br />
    13. 13. Demo<br />
    14. 14. <ul><li>Derivation Constraints</li></ul>class Repo<T> where T : BaseEntity<br />class Repo<T> where T : BaseEntity, IComparable<T><br />class Repo<T, K> where T : BaseEntity<br />where K : IValidator<br /><ul><li>Reference/Value Type Constraints</li></ul>class Repo<T> where T : class<br />class Repo<T> where T : struct<br /><ul><li>Constructor Constraints</li></ul>class Repo<T> where T : class, new()<br />Constraints (C#)<br />
    15. 15. <ul><li>Derivation Constraints</li></ul>Class Repo(Of T As BaseEntity)<br />Class Repo(Of T As {BaseEntity, IComparable(Of T)})<br />Class Repo(Of T As BaseEntity, K As IValidator))<br /><ul><li>Reference/Value Type Constraints</li></ul>Class Repo(Of T As Class)<br />Class Repo(Of T As Structure)<br /><ul><li>Constructor Constraints</li></ul>Class Repo(Of T As New, Class)<br />Constraints (VB.NET)<br />
    16. 16. ?<br />Extension Methods<br />“Extension methods enable you to ‘add’ methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type.”<br />-MSDN<br />
    17. 17. Allows adding methods to an existing type<br />No recompile needed<br />Can extend framework classes (including sealed)<br />Methods included in Intellisense<br />Extension Methods<br />
    18. 18. Demo<br />
    19. 19. ?<br />Lamda Expressions<br />“A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.”<br />-MSDN<br />
    20. 20. <ul><li>Shorthand for a function
    21. 21. A variable that points to function
    22. 22. Anonymous function (no name)
    23. 23. Returns a single value
    24. 24. Explicit or inferred types
    25. 25. Return
    26. 26. Parameter(s)</li></ul>What is a Lambda Anyway?<br />
    27. 27. <ul><li>C#
    28. 28. Arg list => expression
    29. 29. x => x + 1
    30. 30. (x, y) => x == y
    31. 31. VB.NET
    32. 32. Function(x) x + 1
    33. 33. Function(x, y) x = y</li></ul>Syntax Examples<br />
    34. 34. Summary - Wherever a delegate type can be used<br />Event handlers<br />LINQ<br />Projection Extensions (Select, SelectMany)<br />Find Extensions (Find, FindAll)<br />When Can We Use Them?<br />
    35. 35. Demo<br />
    36. 36. ?<br />Language Integrated Query (LINQ)<br />“LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. .”<br />-MSDN<br />
    37. 37. Core functionality provided by extension methods (method based)<br />Any()<br />Where()<br />OrderBy()<br />ThenBy()<br />Contains()<br />Join()<br />First()<br />...<br />LINQ<br />
    38. 38. Expression based<br />var results = from process in Process.GetProcesses()<br /> where process.ProcessName.Contains("WINWORD")<br />orderbyprocess.MainWindowTitle descending<br /> select process;<br />Method based<br />varresults = Process.GetProcesses()<br /> .Where(process=>process.ProcessName<br /> .Contains("WINWORD"))<br /> .OrderBy(x=>x.MainWindowTitle);<br />LINQ Options<br />
    39. 39. Demo<br />
    40. 40. LINQ<br />C#<br />VB<br />Other Languages<br />.NET Language – Integrated Query<br />LINQ enabled data sources<br />LINQ enabled ADO.NET<br />LINQ to Objects<br />LINQ to XML<br />LINQ to Datasets<br />LINQ to SQL<br />LINQ to Entities<br />Objects<br />Relational Data<br />XML<br />
    41. 41. LINQ to …<br />LINQ to Objects<br />LINQ to XML (XLINQ)<br />LINQ to DataSets<br />LINQ to SQL (DLINQ)<br />LINQ to Entities (EF)<br />LINQ to SharePoint<br />LINQ to REST<br />LINQ to NHibernate<br />LINQ to Twitter<br />LINQ to SQL Saturday???<br />
    42. 42. Feature Timeline<br />2.0<br />3.0<br />3.5<br />4.0<br />3.5 SP1<br />2005<br />2006<br />2007<br />2010<br />2008<br />Generics<br /><ul><li>Extensions
    43. 43. LINQ
    44. 44. Lambdas</li></li></ul><li>Key Takeaways<br />Rich productivity improvements in the framework and languages<br />More to explore and learn<br />LINQ is built on all of these<br />You know that you want to roll your own LINQ provider & “Extend it”<br />
    45. 45. @<br />SQL Saturday #28 Baton Rouge<br />.NET Fundamentals<br />Mike Huguet <br /><ul><li>@mhuguet
    46. 46. mike.huguet@sparkhound.com</li>

    ×