IEnumerable VS IQueryable

IEnumerable VS IQueryable

02 Aug 2025
Intermediate
84.9K Views
4 min read
Learn with an interactive course and practical hands-on labs

ASP.NET MVC with Web API Online Course - Learn & Certify

The difference between IEnumerable and IQueryable: An Overview

In this LINQ Tutorial, you will learn the difference between IEnumerable and IQueryable with some actual Programming Examples.In LINQ to query data from databases and collections, we use IEnumerable and IQueryable for data manipulation.

Basically, IQueryable inherits IEnumerable, Hence IQueryable has all the features of IEnumerable and except this, it has its own features. Both have their own methodology to query data and data manipulation. Let’s see both the features and learn how to use both the features to boost your LINQ Query performance.

IEnumerable vs IQueryable

What is IEnumerable?

  1. IEnumerable exists in System.Collections Namespace.

  2. IEnumerable can move forward only over a collection, it can’t move backward and between the items.

  3. IEnumerable is best for querying data from in-memory collections like List, Array, etc.

  4. While querying data from a database, IEnumerable executes a select query on the server side, loads data in memory on the client side, and then filters data.

  5. IEnumerable is suitable for LINQ to Object and LINQ to XML queries.

  6. IEnumerable supports deferred execution.

  7. IEnumerable doesn’t support custom queries.

  8. IEnumerable doesn’t support lazy loading. Hence not suitable for paging-like scenarios.

  9. Extension methods supported by IEnumerable take functional objects.

IEnumerable Example:

 MyDataContext dc = new MyDataContext ();
IEnumerable<Employee> list = dc.Employees.Where(p => p.Name.StartsWith("S"));
list = list.Take<Employee>(10);

Generated SQL statements of the above query will be :

SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
WHERE [t0].[EmpName] LIKE @p0

Explanation:

In the above IEnumerable Example We took the Employee list where we have to find the employee name starting with s, But you noticed that in this query "top 10" is missing since IEnumerable filters record on the client side. Now Let's see in IQueryable.

What is IQueryable?

  1. IQueryable exists in the System. Linq Namespace.

  2. IQueryable can move forward only over a collection, it can’t move backward and between the items.

  3. IQueryable is best for querying data from out-memory (like remote database, service) collections.

  4. While querying data from a database, IQueryable executes the select query on the server side with all filters.

  5. IQueryable is suitable for LINQ to SQL queries.

  6. IQueryable supports deferred execution.

  7. IQueryable supports custom queries using CreateQuery and Execute methods.

  8. IQueryable supports lazy loading. Hence it is suitable for paging-like scenarios.

  9. Extension methods supported by IQueryable take expression objects, which means an expression tree.

IQueryable Example:

MyDataContext dc = new MyDataContext ();
IQueryable<Employee> list = dc.Employees.Where(p => p.Name.StartsWith("S"));
list = list.Take<Employee>(10); 

Generated SQL statements of the above query will be :

SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
WHERE [t0].[EmpName] LIKE @p0

Explanation:

In IQueryable Notice that in this query "top 10" exists since IQueryable executes a query in an SQL server with all filters.

Summary:

In this article, I explained the difference between IEnumerable and IQueryable. I hope after reading this article you will be able to boost your LINQ query performance. I would like to have feedback from my blog readers. Please post your feedback, questions, or comments about this article. Enjoy Coding..!

FAQs

IQueryable is suitable for querying data from out-memory collections. On the other hand IEnumerable is good for In-Memory Collection queries, While querying data from a database, IQueryable executes a "select query" on server side with all filters.

It is used for querying data from external data sources that may not be in memory

It is the collection of extension methods for classes that implement IEnumerable and IQueryable interfaces, therefore the LINQ query applies to any object that implements the IEnumerable or IQueryable interface.
Share Article
About Author
Shailendra Chauhan (Microsoft MVP, Founder & CEO at ScholarHat)

He is a renowned Speaker, Solution Architect, Mentor, and 10-time Microsoft MVP (2016–2025). With expertise in AI/ML, GenAI, System Design, Azure Cloud, .NET, Angular, React, Node.js, Microservices, DevOps, and Cross-Platform Mobile App Development, he bridges traditional frameworks with next-gen innovations.

He has trained 1 Lakh+ professionals across the globe, authored 45+ bestselling eBooks and 1000+ technical articles, and mentored 20+ free courses. As a corporate trainer for leading MNCs like IBM, Cognizant, and Dell, Shailendra continues to deliver world-class learning experiences through technology & AI.
Live Training - Book Free Demo
.NET Solution Architect Certification Training
14 Sep
08:30PM - 10:30PM IST
Checkmark Icon
Get Job-Ready
Certification
ASP.NET Core Certification Training
21 Sep
07:00AM - 09:00AM IST
Checkmark Icon
Get Job-Ready
Certification
.NET Solution Architect Certification Training
28 Sep
05:00PM - 07:00PM IST
Checkmark Icon
Get Job-Ready
Certification
Accept cookies & close this