IEnumerable vs IQueryable in C#
Both are used to hold the collection of data and performing data manipulation activities.
IEnumerable will retrieve all records from database and doing other data manipulation activities in client. This data can't be modified (insert/delete).
IQueryable will do data manipulation activities in database and return only the final data to client. It will give high performance.
Example
Assume Employee table has 1000 records. We need to retrieve only "IT" employees.
*IEnumerable
Loads all employee in memory.
Filters "IT" employees
*IQueryable
Filters "IT" employees from database and return .
IEnumerable will retrieve all records from database and doing other data manipulation activities in client. This data can't be modified (insert/delete).
IQueryable will do data manipulation activities in database and return only the final data to client. It will give high performance.
Example
Assume Employee table has 1000 records. We need to retrieve only "IT" employees.
*IEnumerable
Loads all employee in memory.
Filters "IT" employees
*IQueryable
Filters "IT" employees from database and return .
Comments
Post a Comment