Linq (from the inside)
Upcoming SlideShare
Loading in...5
×
 

Linq (from the inside)

on

  • 2,319 views

Knowing how to use Linq is useful if you're doing any coding using .NET 3.5 or newer. But have you ever thought about what is going on "under the hood"?...

Knowing how to use Linq is useful if you're doing any coding using .NET 3.5 or newer. But have you ever thought about what is going on "under the hood"?

Join us as we dive into the guts of Linq and implement Linq extension methods such as Where, Select, Any, All and Aggregate. Not only is it interesting to see what's going on, it'll help you to build better code using Linq.

Statistics

Views

Total Views
2,319
Views on SlideShare
1,782
Embed Views
537

Actions

Likes
0
Downloads
15
Comments
0

5 Embeds 537

http://blog.softwareontheside.com 488
http://speakerrate.com 33
http://feeds.feedburner.com 9
http://7414512759580466_9b3378270d5380bba828e28eee71721220422263.blogspot.com 4
http://theoldreader.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Not Link cosplay! Not that there’s anything wrong with that…
  • The “other” Microsoft “link”
  • Language-Integrated QueryQuery is first class citizen in languageQueries are consistent across data sourcesOne query language to rule them all
  • Don’t want to get too far in without recognizing the true brains behind this presentation.
  • 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)
  • 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.
  • 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.
  • Linq operators are defined as extension methods on IEnumerableSo 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.
  • Going to pull back the curtain
  • Unfortunately it may feel like this for a little bit…House in Poland
  • Going to pull back the curtain
  • 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.

Linq (from the inside) Linq (from the inside) Presentation Transcript

  • 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 andLINQ to Bindable Sources (SyncLINQ) PostgreSql (DbLinq)LINQ to C# project LINQ to NCoverLINQ to Continuous Data (CLinq) LINQ to Opf3LINQ to CRM LINQ to Parallel (PLINQ)LINQ To Geo - Language Integrated Query for LINQ to RDF FilesGeospatial Data LINQ to SharepointLINQ to Excel LINQ to SimpleDBLINQ to Expressions (MetaLinq) LINQ to StreamsLINQ Extender (Toolkit for building LINQ LINQ to TwitterProviders) LINQ to WebQueriesLINQ to Flickr LINQ to WMILINQ to Google http://tomasp.net/blog/linq-LINQ to Indexes (LINQ and i40) expand.aspxLINQ to IQueryable (Matt Warren on http://tomasp.net/blog/linq-expand-Providers) update.aspxLINQ to JSON Linq To WIQLLINQ to LDAP LINQ to XtraGridLINQ to NHibernateLINQ to JavaScript Source:LINQ to LLBLGen Pro http://blogs.msdn.com/b/charlie/archive/20LINQ to Lucene 06/10/05/links-to-linq.aspx
  • If I have seenfurther it is bystanding on theshoulders 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 customerswhere 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 methodpublic static voidMethod(this IInterfacemyInterface, 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