IQueryable<T>

As you’ve seen before, LINQ to Objects operates on plain IEnumerable<T> objects, executing the query using the magic of iterators. All of this happens in memory in the same process as where the collection object is living. The brother to IEnumerable<T> allowing for remote execution of queries is called IQueryable<T> and is based on the concept of expression trees.

Let’s first take a look at the interface to set the scene. As shown here, every type that implements IQueryable<T> also implements IEnumerable<T>, which provides support to enumerate over the object. It’s this enumeration that will trigger the query captured by the queryable object to be translated and executed (for example, by sending a piece of T-SQL to a database server ...

Get C# 4.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.