Click here to Skip to main content
12,627,681 members (34,079 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

104.8K views
36 bookmarked
Posted

IEnumerable Vs IQueryable

, 24 Feb 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
IEnumerable Vs IQueryable

Many developers get confused between IEnumerable and IQueryable. When it comes to writing code, both look very similar. However, there are many differences between them which need to be taken care of while writing code. Both have some intended usability scenarios for which they are made.

Listed below are the differences between them based on their properties:

  IEnumerable IQueryable
Namespace System.Collections Namespace System.Linq Namespace
Derives from No base interface Derives from IEnumerable
Deferred Execution Supported Supported
Lazy Loading Not Supported Supported
How does it work While querying data from database, IEnumerable executes select query on server side, load data in-memory on client side and then filter data. Hence does more work and becomes slow. While querying data from database, IQueryable executes select query on server side with all filters. Hence does less work and becomes fast.
Suitable for LINQ to Object and LINQ to XML queries LINQ to SQL queries
Custom Query Doesn’t support Supports using CreateQuery and Execute methods
Extension method
parameter
Extension methods supported in IEnumerable takes functional objects. Extension methods supported in IEnumerable takes 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

License

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

Share

About the Author

Adarsh Chaurasia - Enjoying Full Stack Development
Software Developer (Senior)
India India
 Innovative & tech-savvy software development professional with 6+ years of progressive experience specializing in object-oriented approach to enterprise commercial solution delivery utilizing latest technologies.
 Extensive background in Full Life-Cycle of Software Development and Automation process including requirements gathering, design, coding, unit testing, automation, debugging and maintenance.
 Comprehensive knowledge of Relational Database technology, queries and procedures.
 Excellent understanding of OOPS Concepts, Design Patterns & Best Coding Practices.
 Strong architectural knowledge of designing n-tier and n-layer solutions using Application blocks, Enterprise library, SOA, Software factories.
 Working experience of IIS administration and website deployment and configuration.

Strengths & Area of expertise include:

 Full Stack Enterprise Web Development
 Multi-Threaded Programming
 Object Oriented Development
 REST APIs Development & Integration
 Distributed/Client Server System
 TDD & Behavior Driven Development (BDD)
 Database Design & Development
 Exceptional Analytical & Quick Learning Skill
 Team & Client Communication
 Proactive & Organization Development Attitude

You may also be interested in...

Comments and Discussions

 
PraiseGood effects Pin
hebsiboy22-Oct-16 20:12
memberhebsiboy22-Oct-16 20:12 
GeneralMy vote of 5 Pin
girishmeena28-Aug-16 5:54
membergirishmeena28-Aug-16 5:54 
QuestionIEnumerable Linq capabilities Pin
girishmeena28-Aug-16 5:52
membergirishmeena28-Aug-16 5:52 
QuestionThanks Pin
Pawan Tiwari9315-May-16 20:49
professionalPawan Tiwari9315-May-16 20:49 
QuestionGood Short Descriptive Pin
Er. Puneet Goel6-Apr-16 1:46
professionalEr. Puneet Goel6-Apr-16 1:46 
GeneralGood Work Pin
Alireza_13623-Apr-16 9:21
memberAlireza_13623-Apr-16 9:21 
GeneralMy vote of 5 Pin
Chinh Vo Wili27-Jan-16 5:01
professionalChinh Vo Wili27-Jan-16 5:01 
GeneralRe: My vote of 5 Pin
Adarsh Chaurasia (Learner|Consultant|Mentor|Tech22-Mar-16 6:58
professionalAdarsh Chaurasia (Learner|Consultant|Mentor|Tech22-Mar-16 6:58 
Suggestiongood article Pin
toumir24-Nov-15 23:38
membertoumir24-Nov-15 23:38 
QuestionDifference between IEnumerable VS IQueryable:- Pin
Member 1057063910-Aug-15 19:23
memberMember 1057063910-Aug-15 19:23 
QuestionThank you Pin
Mahsa Hassankashi20-Sep-14 13:11
memberMahsa Hassankashi20-Sep-14 13:11 
AnswerRe: Thank you Pin
Member 408341017-Jun-15 6:51
memberMember 408341017-Jun-15 6:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 24 Feb 2014
Article Copyright 2014 by Adarsh Chaurasia - Enjoying Full Stack Development
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid