Wednesday, September 1, 2010

DEV401 LINQ Confidential: A Deep Dive Into How LINQ Works

Speaker(s): Ivan Towlson

Consumers versus interface implementers

EnumerableHelpers.
- Extension methods
- Lambda expressions
- var - let the compiler figure out the type (type inference)

How the compiler compiles LINQ queries.

IEnumerable.Where(...)
- Translation by compiler is naive/straight forward.
- Allows normal method resolution after first pass translation.
- Would pull all data from datasource and then filter

LINQ is very sensitive to the compile time type as to which methods get resolved to.

IQueryable
- Returns sequence in the same way as IEnumerable but defers to IQueryProvider that runs the actual query.

Lambda is not exactly the same as a delegate. Could be determined as an expression depending on the target(how they are used). Prefers Expressions over delegates when possible.

Lambda expression can't compile to var as it must explicitly go to Func or Expression.

Turing an expression tree into an acutal query.

IQueryable.Create
IQueryable.Execute()