In this article I will demonstrate how to write code via IEnumerable and IQueryable and what the differences are between them.
IEnumerable and IQueryable are used for data manipulation in LINQ from the database and collections.
For getting the data from the database, I have created a table named "Employee" that has some data and looks like:

Then creating the Data Context class (.dbml class) in your project that converts the database table named "Employee" as a class.
Now I will tell you the functionality and some basic differences between IEnumerable and IQueryable using the object of the Data Context class..
IEnumerable Code

SQL statement after execution of above query
After the execution of line number 18, the SQL statement will look like the following until the end:

IQueryable Code

SQL statement after execution of the preceding query
After the execution of line number 22, the SQL statement will look like:

But after the execution of line number 23, SQL statement will add the Top for the filtering.

In both syntaxes I am accessing the data from the Employee table and then taking only 3 rows from that data.
Differences
IEnumerable
- IEnumerable exists in the System.Collections namespace.

- IEnumerable is suitable for querying data from in-memory collections like List, Array and so on.
- 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.

- IEnumerable is beneficial for LINQ to Object and LINQ to XML queries.
IQueryable
- IQueryable exists in the System.Linq Namespace.

- IQueryable is suitable for querying data from out-memory (like remote database, service) collections.
- While querying data from a database, IQueryable executes a "select query" on server-side with all filters.
- IQueryable is beneficial for LINQ to SQL queries.

Bahman ShafieiPosted Apr 4, 2024, 6:34 AM
Unfortunately this article was not clear for me.
Ammar ShaukatPosted Jul 1, 2022, 11:45 AM
Thanks @Rahul Bansal for explaining this in such an easy way..
Sudheshwer RaiPosted Oct 23, 2021, 4:25 PM
I don't know how C# Corner Approved this article. There is multiple error and still this article is running. Man, please correct it.
Muhammad Shahid Khan AfridiPosted Jul 13, 2021, 2:50 AM
Lots of mistakes were found in this article, you should review it again and make some changes so that it will provide useful information to newbies.
Naresh KumarPosted May 26, 2021, 9:05 AM
Correct the article please
Roshan RathodPosted Jul 23, 2020, 4:25 AM
Good article..keep it up sir
Hemant SoniPosted Apr 5, 2020, 9:11 PM
In statement "After the execution of line number 18", where is Lin 18?? and at the time of explaining "IEnumerable Code" used IQuriable, Please check code and correct that.
Sujeet SinghPosted Feb 19, 2020, 12:51 AM
"After the execution of line number 18" where is Lin 18??
Kumaresan MurugesanPosted Aug 11, 2019, 4:57 AM
Nice Article
Ozmen GokPosted Jan 22, 2019, 12:13 PM
It is Very clear explanation, I want to add a thing only, to clearify , when you refer server side on "While querying data from a database, IQueryable executes a "select query" on server-side with all filters." , you mention about DATABASE and "While querying data from the database, IEnumerable executes "select query" on the server-side, loads data in-memory on the client-side " here server side still refers DATABASE and client side refers IN MEMORY(execution our CSHARP code), AM I TRUE?
Micro techiePosted Jan 8, 2019, 3:33 AM
Very straight forward explanation thank you very much
Brijesh MavaniPosted Dec 7, 2018, 12:55 AM
Performance wise which one is good?
neeraj kanojiyaPosted Nov 23, 2018, 1:19 AM
Very good example given.
jubula samalPosted Nov 16, 2018, 12:34 AM
Explained superbly
Navjyot YadavPosted Nov 13, 2018, 11:27 AM
Performance wise which one is more preferred?
Stephen DevasyPosted Nov 7, 2018, 4:37 AM
Thanks sir very easy to understand
Dinesh Kumar SharmaPosted Aug 28, 2018, 6:48 AM
Thank Sir very nice article
Razat KumarPosted Aug 6, 2018, 3:57 AM
Thanks, very nice article
Shakir AliPosted May 31, 2018, 3:03 PM
Very Nice explanation....
Istekhar AhmadPosted Mar 30, 2018, 7:19 AM
Nice one explain clearly.
Dennis ThomasPosted Mar 6, 2018, 1:56 AM
Good explanation Rahul. Thanks!
shruti patilPosted Mar 1, 2018, 10:38 PM
Clearly explained,thank you!
MaharajaPosted Sep 22, 2017, 3:26 AM
Understood . Thanks
zul ismailPosted Aug 7, 2017, 6:18 AM
Very clear explanation, thanks.
RonakPosted Sep 24, 2016, 2:13 AM
Good article with explanation. Thanks
gowtham vPosted Oct 12, 2015, 12:33 AM
Thank you