IQueryable<T>
Return IQueryable<T>
from a WebApi endpoint when you want to allow artitrary server-side filtering and paging. For example, to allow the client to arbitrarily query the products database:
public IQueryable<Product> Get()
{
return allProducts.AsQueryable();
}
The client can then construct arbitrary queries such as:
http://localhost/odata/Products?$orderby=Category,Price desc
http://localhost/Products?$filter=substringof('zz',Name)
Return IQueryable<T>
from a class library when all of the following are true:
IEnumerable<T>
).An example is a LINQ to SQL provider. The C# expression tree provided by the consumer is translated into actual SQL statements that can be executed by the target database. Note: this is a dark art and not for the faint-hearted.