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# 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.