Another interesting tidbit I learned about at the summit was deferred execution of LINQ queries.
Here's an example that highlights what deferred execution means to you. Let's create a Customer class and then build up a list of customers:
Now assume we're going to run a query to find all Customers whose first name begins with a particular letter (supplied in a variable):
What do you think prints out? Due to deferred execution, the application will only print "Joe", not "Bill" and "Bob" as you might expect.
The code executed in line 4 only builds the query into a query expression tree. And that expression tree includes a reference to the "firstLetter" variable, not its contents. The expression tree is not executed until line 9 when a foreach loop is used. As a result, the value of the "firstLetter" variable is not obtained until line 9.
So be careful how you use locally-scoped variables in your LINQ queries and be aware of deferred execution in LINQ queries.