You are on page 1of 2

IEnumerable Vs IQueryable - CodeProject

http://www.codeproject.com/Articles/732425/IEnumerable-Vs-IQuery...

Articles General Reading Uncategorised Technical Blogs General

IEnumerable Vs IQueryable
Adarsh Chaurasia (Consultant|Mentor|Tech Savvy), 24 Feb 2014

CPOL

4.76 (26 votes)

Many developers gets confused between IEnumerable and IQueryable. When it comes to writing code, both looks very
similar. However there are many difference between them which needs to be taken care of while writing code. Both have
some intended usability scenarios for which they are made. Below lis
Many developers gets confused between IEnumerable and IQueryable. When it comes to writing code, both looks very
similar. However there are many difference between them which needs to be taken care of while writing code. Both have
some intended usability scenarios for which they are made.
Below lists the differences between them based on their properties :

Namespace
Derives from
Deferred Execution
Lazy Loading

IEnumerable
System.Collections Namespace
No base interface
Supported
Not Supported

IQueryable
System.Linq Namespace
Derives from IEnumerable
Supported
Supported

How does it work

While querying data from database,


IEnumerable execute select query on server While querying data from database, IQueryable execute
side, load data in-memory on client side and select query on server side with all filters. Hence does
then filter data. Hence does more work and less work and becomes fast.
becomes slow.

Suitable for
Custom Query

LINQ to Object and LINQ to XML queries.


Doesnt supports.

Extension mehtod
parameter

Extension methods supported in IEnumerable Extension methods supported in IEnumerable takes


takes functional objects.
expression objects i.e. expression tree.

When to use

when querying data from in-memory


collections like List, Array etc.

when querying data from out-memory (like remote


database, service) collections.

Best Uses

In-memory traversal

Paging

LINQ to SQL queries.


Supports using CreateQuery and Execute methods.

License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share
About the Author

1 of 2

10/23/2014 11:41 AM

IEnumerable Vs IQueryable - CodeProject

http://www.codeproject.com/Articles/732425/IEnumerable-Vs-IQuery...

Adarsh Chaurasia (Consultant|Mentor|Tech Savvy)


Software Developer (Senior)
India

I have 4.6+ years of experience in SaaS, SOA based Enterprise Web Application design and development using Microsoft
technology stack. I have mostly worked on Business layer, Data access layer, WCF, Entity Framework, Microsoft Application
Blocks, Search engines, APIs integration, Third party APIs/Product Research & Development.
I am a huge fan of Design Patterns. I also work as Software Consultant. I read/write blogs, help and learn from other
developers.
Follow on

Twitter

LinkedIn

Comments and Discussions


1 message has been posted for this article Visit http://www.codeproject.com/Articles/732425/IEnumerable-Vs-IQueryable
to post and view comments on this article, or click here to get a print view with messages.

Permalink | Advertise | Privacy | Mobile


Web03 | 2.8.141022.1 | Last Updated 24 Feb 2014

2 of 2

Article Copyright 2014 by Adarsh Chaurasia (Consultant|Mentor|Tech Savvy)


Everything else Copyright CodeProject, 1999-2014
Terms of Service

10/23/2014 11:41 AM

You might also like