
The Virtues of Being Lazy
When you build a LINQ query expression and assign it to a query variable, very little code is exe-
cuted in that statement. The data only becomes available when you iterate over that query variable,
which executes the query once for each result in the result set. So, for example, if the result set con-
sists of 100 items and you only iterate over the first ten, then you don’t pay the price for computing
the remaining 90 items in the result set.
■Note You can use the Take extension method to reduce the number of items in the result set; however, it still
produces an enumerator that uses deferred execution. Similarly useful ...