Q:

What are the differences between IEnumerable and IQueryable?

0

What are the differences between IEnumerable and IQueryable?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

There are some differences between an IEnumerable and an IQueryable that I have arranged in a table for easier comparison:

IEnumerable

IQueryable

IEnumerable belongs to System.Collections Namespace. IQueryable belongs to System.Linq Namespace
It has no base interface It derives from IEnumerable
 does not support Lazy Loading.  Support Lazy Loading.
While querying data from the database, IEnumerable executes a select query on the server-side, load data in-memory on client-side and then filter data. Hence does more work and becomes slow. While querying data from the database, IQueryable executes select queries on the server-side with all filters. Hence does less work and becomes fast.
It suitable for LINQ to Object and LINQ to XML queries It is suitable for LINQ to SQL queries.
Doesn’t support Custom Query Supports Custom Query using CreateQuery and Execute methods
Extension methods supported in IEnumerable takes functional objects. Extension methods supported in IEnumerable takes expression objects, i.e., expression tree.
IEnumerable is used when querying data from in-memory collections like List, Array, etc. IQueryable is used When querying data from out-memory (like remote database, service) collections.
Its best use in-memory traversal Its best use in Paging.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Interview Questions and Answers,You Need To Know

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is Reflection in C#?... >>
<< What is the difference between late binding and ea...