Monday, June 20, 2016

Default return type of LINQ Query

If you are querying a database(Linq to SQL) then the return type is IQueryable<T> where T is Product in below example
var product = from p in dbContext.Products
             select p;


If you are using Linq againist a datasource which is an Enumerable collection(List) then the return type will be IEnumerable<t>
------------------------------------------
it depends on your original data source. It can be either IEnumerable or IQueryable 

The result of a Linq database query is typically IQueryable<T> . 

If the database query includes an OrderBy clause, the type is IOrderedQueryable<T> .It is derive from IQueryable<T> 

If the data source is an IEnumerable, the result type is IEnumerable<T> 

You can find out the datatype by calling .GetType() on the source.