What you are referring to is known as deferred execution. What this basically entails is that as long as you don't call ToList()
, ToArray()
or any other method that casts your LINQ query directly to a collection, that query is executed at the moment the variable it is assigned to is used.
Up until the point to when your query is used, the IEnumerable
is not enumerated. However, I don't think GetEnumerator
overridden in the case of deferred execution.
Here's an MSDN blog regarding this specific subject: http://blogs.msdn.com/b/charlie/archive/2007/12/09/deferred-execution.aspx