Thursday 14 May 2015

Difference between IEnumerable vs IQueryable in LINQ


IEnumerable:-
1:-IEnumerable exists in the System.Collections namespace.
2:- IEnumerable is suitable for querying data from in-memory collections like List, Array and so on
3:- While querying data from the database, IEnumerable executes "select query" on the server-side, loads data in-memory on the client-side and then filters the data. 
4:- IEnumerable is beneficial for LINQ to Object and LINQ to XML queries.
IQueryable:-
1:- IQueryable exists in the System.Linq Namespace.
2:- IQueryable is suitable for querying data from out-memory (like remote database, service) collections.
3:- While querying data from a database, IQueryable executes a "select query" on server-side with all filters.
4:- IQueryable is beneficial for LINQ to SQL queries.

No comments:

Post a Comment