What Is The Difference Between IEnumerable And IQueryable in C#
Answers (2)
Add AnswerIEnumerable
IEnumerable exists in the System.Collections namespace.
IEnumerable is suitable for querying data from in-memory collections like List, Array.
IEnumerable is beneficial for LINQ to Object and LINQ to XML queries.
IEnumerable is slower than IQueryable because 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.
IQueryable
IQueryable exists in the System.Linq Namespace.
IQueryable is suitable for querying data from out-memory (like remote database, service) collections.
IQueryable is beneficial for LINQ to SQL queries.
IQueryable is faster than IEnumerable because while querying data from a database, IQueryable executes a “select query” on server-side with all filters