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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.