KEMBAR78
Linq (from the inside) | PPTX
Linq (from the inside)

Reinventing the Linq to Objects wheel
           Mike Clement
   mike@softwareontheside.com
            @mdclement
LINQ to Amazon                              LINQ to Metaweb(freebase)
LINQ to Active Directory                    LINQ to MySQL, Oracle and
LINQ to Bindable Sources (SyncLINQ)         PostgreSql (DbLinq)
LINQ to C# project                          LINQ to NCover
LINQ to Continuous Data (CLinq)             LINQ to Opf3
LINQ to CRM                                 LINQ to Parallel (PLINQ)
LINQ To Geo - Language Integrated Query for LINQ to RDF Files
Geospatial Data                             LINQ to Sharepoint
LINQ to Excel                               LINQ to SimpleDB
LINQ to Expressions (MetaLinq)              LINQ to Streams
LINQ Extender (Toolkit for building LINQ    LINQ to Twitter
Providers)                                  LINQ to WebQueries
LINQ to Flickr                              LINQ to WMI
LINQ to Google                                   http://tomasp.net/blog/linq-
LINQ to Indexes (LINQ and i40)                   expand.aspx
LINQ to IQueryable (Matt Warren on               http://tomasp.net/blog/linq-expand-
Providers)                                       update.aspx
LINQ to JSON                                Linq To WIQL
LINQ to LDAP                                LINQ to XtraGrid
LINQ to NHibernate
LINQ to JavaScript                          Source:
LINQ to LLBLGen Pro                         http://blogs.msdn.com/b/charlie/archive/20
LINQ to Lucene                              06/10/05/links-to-linq.aspx
If I have seen
further it is by
standing on the
shoulders of giants.
           -Sir Issac Newton
http://stackoverflow.com/users/22656/jon-skeet
• Jon Skeet is immutable. If something’s going to change, it’s going
  to have to be the rest of the universe.
• Jon Skeet is the only top 100 SO user who is human. The others
  are bots that he coded to pass the time between questions.
• Jon Skeet does not use revision control software. None of his
  code has ever needed revision.
• When Jon Skeet’s code fails to compile, the compiler apologizes.
• Jon Skeet is the traveling salesman. Only he knows the shortest
  route.
• The Dining Philosophers wait while Jon Skeet eats.
• When Jon Skeet points to null, null quakes in fear.
• Jon Skeet does not use exceptions when programming. He has
  not been able to identify any of his code that is not exceptional.
• Jon Skeet has already written a book about
  C# 5.0.
• It’s currently sealed up.
• In three years, Anders Hejlsberg is going to
  open the book to see if the language design
  team got it right
from cust in customers
where cust.City == "London"
select cust;

customers.Where(
cust => cust.City == "London");
C# Language Features
•   Query Expressions
•   Implicitly Typed Variables
•   Object and Collection Initializers
•   Anonymous Types
•   Extension Methods
•   Lambda Expressions
•   Auto-implemented Properties

• Iterator blocks
• Generics
Anatomy of an extension method

public static void
Method(this IInterface
myInterface, int i)
Learning by Doing… we’ll figure it out as we go.

IMPLEMENT LINQ TO OBJECTS
C# Language Features
•   Query Expressions
•   Implicitly Typed Variables
•   Object and Collection Initializers
•   Anonymous Types
•   Extension Methods
•   Lambda Expressions
•   Auto-implemented Properties

• Iterator blocks
• Generics
Resources
•   Classification by Manner of Execution
•   C# Features
•   List of Linq Providers (and other links)
•   EduLinq code blog posts (from Jon Skeet)
•   MoreLinq (from Jon Skeet)
•   My Starter Project
    – https://github.com/mdclement/Linq--from-the-
      inside--Presentation-Base
Action Items!
• Read Jon Skeet’s EduLinq series.
• Download my “starter” and play!
• If you aren’t already, use Linq in your everyday
  coding.
• Look for other Linq operators to implement.
• Attend the Utah Software Craftsmanship
  Group!
Me
•   @mdclement
•   mike@softwareontheside.com
•   http://blog.softwareontheside.com
•   Utah Software Craftsmanship Group
    – https://groups.google.com/forum/#!forum/ut-
      software-craftsmanship
    – @utahsc
    – First Wednesday, Neumont, Room 300

Linq (from the inside)

  • 1.
    Linq (from theinside) Reinventing the Linq to Objects wheel Mike Clement mike@softwareontheside.com @mdclement
  • 7.
    LINQ to Amazon LINQ to Metaweb(freebase) LINQ to Active Directory LINQ to MySQL, Oracle and LINQ to Bindable Sources (SyncLINQ) PostgreSql (DbLinq) LINQ to C# project LINQ to NCover LINQ to Continuous Data (CLinq) LINQ to Opf3 LINQ to CRM LINQ to Parallel (PLINQ) LINQ To Geo - Language Integrated Query for LINQ to RDF Files Geospatial Data LINQ to Sharepoint LINQ to Excel LINQ to SimpleDB LINQ to Expressions (MetaLinq) LINQ to Streams LINQ Extender (Toolkit for building LINQ LINQ to Twitter Providers) LINQ to WebQueries LINQ to Flickr LINQ to WMI LINQ to Google http://tomasp.net/blog/linq- LINQ to Indexes (LINQ and i40) expand.aspx LINQ to IQueryable (Matt Warren on http://tomasp.net/blog/linq-expand- Providers) update.aspx LINQ to JSON Linq To WIQL LINQ to LDAP LINQ to XtraGrid LINQ to NHibernate LINQ to JavaScript Source: LINQ to LLBLGen Pro http://blogs.msdn.com/b/charlie/archive/20 LINQ to Lucene 06/10/05/links-to-linq.aspx
  • 8.
    If I haveseen further it is by standing on the shoulders of giants. -Sir Issac Newton
  • 9.
  • 10.
    • Jon Skeetis immutable. If something’s going to change, it’s going to have to be the rest of the universe. • Jon Skeet is the only top 100 SO user who is human. The others are bots that he coded to pass the time between questions. • Jon Skeet does not use revision control software. None of his code has ever needed revision. • When Jon Skeet’s code fails to compile, the compiler apologizes. • Jon Skeet is the traveling salesman. Only he knows the shortest route. • The Dining Philosophers wait while Jon Skeet eats. • When Jon Skeet points to null, null quakes in fear. • Jon Skeet does not use exceptions when programming. He has not been able to identify any of his code that is not exceptional.
  • 11.
    • Jon Skeethas already written a book about C# 5.0. • It’s currently sealed up. • In three years, Anders Hejlsberg is going to open the book to see if the language design team got it right
  • 12.
    from cust incustomers where cust.City == "London" select cust; customers.Where( cust => cust.City == "London");
  • 13.
    C# Language Features • Query Expressions • Implicitly Typed Variables • Object and Collection Initializers • Anonymous Types • Extension Methods • Lambda Expressions • Auto-implemented Properties • Iterator blocks • Generics
  • 14.
    Anatomy of anextension method public static void Method(this IInterface myInterface, int i)
  • 18.
    Learning by Doing…we’ll figure it out as we go. IMPLEMENT LINQ TO OBJECTS
  • 21.
    C# Language Features • Query Expressions • Implicitly Typed Variables • Object and Collection Initializers • Anonymous Types • Extension Methods • Lambda Expressions • Auto-implemented Properties • Iterator blocks • Generics
  • 22.
    Resources • Classification by Manner of Execution • C# Features • List of Linq Providers (and other links) • EduLinq code blog posts (from Jon Skeet) • MoreLinq (from Jon Skeet) • My Starter Project – https://github.com/mdclement/Linq--from-the- inside--Presentation-Base
  • 23.
    Action Items! • ReadJon Skeet’s EduLinq series. • Download my “starter” and play! • If you aren’t already, use Linq in your everyday coding. • Look for other Linq operators to implement. • Attend the Utah Software Craftsmanship Group!
  • 24.
    Me • @mdclement • mike@softwareontheside.com • http://blog.softwareontheside.com • Utah Software Craftsmanship Group – https://groups.google.com/forum/#!forum/ut- software-craftsmanship – @utahsc – First Wednesday, Neumont, Room 300

Editor's Notes

  • #4 Not Link cosplay! Not that there’s anything wrong with that…
  • #5 The “other” Microsoft “link”
  • #8 Language-Integrated QueryQuery is first class citizen in languageQueries are consistent across data sourcesOne query language to rule them all
  • #9 Don’t want to get too far in without recognizing the true brains behind this presentation.
  • #10 Monster on StackOverflowWrote “C# In Depth” (excellent read… I need to pick up the second edition)Wrote the Edulinq blog posts (and project that I’m based on today)
  • #13 http://msdn.microsoft.com/en-us/library/bb882642.aspxSo back to Linq…Query Expression Syntax vs. Extension MethodsNote that given the providers, “customers” could be XML, a database, a web service…But then they split it into two different syntaxes? Syntacies?“real” linq (integrated query) only supports a subset of what the full extension methods support.
  • #14 These language features are used to implement Linq either explicitly or “from the inside”Query syntax inlinevar keywordCustomer cust = new Customer { Name = "Mike", Phone = "555-1212" };An anonymous type is constructed by the compiler and the type name is only available to the compiler. Anonymous types provide a convenient way to group a set of properties temporarily in a query result without having to define a separate named type. An extension method is a static method that can be associated with a type, so that it can be called as if it were an instance method on the type. This feature enables you to, in effect, "add" new methods to existing types without actually modifying them.A lambda expression is an inline function that uses the => operator to separate input parameters from the function body and can be converted at compile time to a delegate or an expression tree.the compiler will create a private, anonymous backing field that is not accessible except through the property getter and setter.
  • #15 Linq operators are defined as extension methods on IEnumerable<T>So it’s important that we understand the anatomy of extension methods.Extension methods are defined as static methods but are called by using instance method syntax. Their first parameter specifies which type the method operates on, and the parameter is preceded by the this modifier. Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive.
  • #17 Going to pull back the curtain
  • #18 Unfortunately it may feel like this for a little bit…House in Poland
  • #21 Going to pull back the curtain
  • #22 These language features are used to implement Linq either explicitly or “from the inside”Query syntax inlinevar keywordCustomer cust = new Customer { Name = "Mike", Phone = "555-1212" };An anonymous type is constructed by the compiler and the type name is only available to the compiler. Anonymous types provide a convenient way to group a set of properties temporarily in a query result without having to define a separate named type. An extension method is a static method that can be associated with a type, so that it can be called as if it were an instance method on the type. This feature enables you to, in effect, "add" new methods to existing types without actually modifying them.A lambda expression is an inline function that uses the => operator to separate input parameters from the function body and can be converted at compile time to a delegate or an expression tree.the compiler will create a private, anonymous backing field that is not accessible except through the property getter and setter.