Differences between them based on their properties :
IEnumerable
- Namespace: System.Collections Namespace
- Derives from: No base interface
- Deferred Execution : Supported
- Lazy Loading : Not Supported
- How does it work : While querying data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data. Hence does more work and becomes slow.
- Suitable for : LINQ to Object and LINQ to XML queries.
- Custom Query : Doesn’t supports.
- Extension method parameter : Extension methods supported in IEnumerable takes functional objects.
- When to use : When querying data from in-memory collections like List, Array etc.
- Best Uses : In-memory traversal
IQueryable
- Namespace: System.Linq Namespace
- Derives from: Derives from IEnumerable
- Deferred Execution : Supported
- Lazy Loading : Supported
- How does it work : While querying data from database, IQueryable execute select query on server side with all filters. Hence does less work and becomes fast.
- Suitable for : LINQ to SQL queries.
- Custom Query : Supports using CreateQuery and Execute methods.
- Extension method parameter : Extension methods supported in IEnumerable takes expression objects i.e. expression tree.
- When to use : When querying data from out-memory (like remote database, service) collections.
- Best Uses : Paging