Showing posts from February, 2009

LINQ is not just LINQ to SQL

Deconstructing a LINQ Statement (download source code: ) LINQ is a valuable tool, but because of the way it is usually demonstrated, developers think that its only use is for querying a Microsoft SQL Server database. This is because it is usually being demonstrated along with "LINQ to SQL". LINQ is not just LINQ to SQL . I like to think of LINQ as a shorthand (or syntax shortcut) way of writing code - a way to write less lines of code (or simplify code), but still perform the same operations (kind of like what foreach is to the for loop). I would like to demonstrate LINQ in a way that does not use LINQ to SQL. I will break down a LINQ statement into lines of code that developers might be more familiar with in an attempt to show what is going on under the covers. I will start with code that hopefully everyone has seen/written before, then build up to a LINQ statement that performs the same operation.