Northern Colorado .NET User Group Under the Hood of LINQ Presentation

Tonight I gave a 90 minute deep dive talk on LINQ to Objects at the Northern Colorado .NET SIG.  As requested, here is the slide deck which is pretty minimal and the sample code that we spent the bulk of the time reviewing.  For those who didn’t attend the presentation, the sample code might be a bit of a challenge to follow.  The general gist of the sample code is this.  In CSharp2.0\Program2_.0.cs I review some foundational features added in .NET 2.0 that are crucial to the implementation of LINQ.  Those .NET 2.0 features are:

  • Generic Methods/Delegates/Interfaces
  • Anonymous methods
  • Iterators

After reviewing those features I then show my own scaled down implementation of LINQ in C# 2.0. Please be sure to look at the CSharp2.0\Pipes.cs source to see how I implemented my query operators.  Then at the bottom of the Program2_0.cs file, in the Pipelines region, you can see what my LINQ query looks like.  If you execute the query, you will see that it is indeed a functional implementation of my subset of LINQ.  Unfortunately its appearance and usability are absolutely horrid.

Then switch over to the CSharp3.0\Program3_0.cs file.  Here you will see how I apply each of the LINQ-oriented C# 3.0 features to my implementation of LINQ.  Each C# 3.0 language feature incrementally improves the usability of my LINQ implementation up to the point that it is practically identical to Microsoft’s implementation of LINQ.  Well, at least how they implement my small subset of LINQ without, er, any error checking.

In the query expressions region note that you can execute the C# query expression form (from c in GetPCStats(5,200) where …) and it actually works.  What makes that surprising is that I haven’t included a "using System.Linq" statement in this file.  The C# query expression form is still using *my implementation* of LINQ.  For me that shows how the C# team at Microsoft implemented LINQ in a very nice and extensible manner.

Anyway here are the files.  Enjoy!

http://cid-5a8d2641e0963a97.skydrive.live.com/embedrowdetail.aspx/Public/NorthernCODotnetUG-2008-09-08/UndertheHoodofLINQandC|33.0.pptxhttp://cid-5a8d2641e0963a97.skydrive.live.com/embedrowdetail.aspx/Public/NorthernCODotnetUG-2008-09-08/LINQUnderTheHood.zip

Advertisements
This entry was posted in LINQ. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s