How LINQ to Objects Works

So far, we’ve been looking at various query expression clauses that enable us to express queries, no matter that data domain we’re targeting. Even though most of our examples assumed in-memory data collections, all those queries would have worked equally well against, say, a relational database.

Because in-memory data is common, it makes sense for us to delve a little deeper into how LINQ support for those data collections is provided. This leads us to a discussion about the IEnumerable and IEnumerator interfaces, iterators, and LINQ to Objects. From this exploration, it will become clear how query expressions are executed lazily and what the implications of this execution model are.

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.