What is the use of IQueryable in the context of Linq.
means How can use IQueryable and how it is better from IEnumerable?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jun 13, 2011, 8:48 PM EDT
First of all, IQueryable
IEnumerable
What IQueryable
The expression can simply be a constant expression of the object itself or a more complex tree of a composed set of query operators and operands. The query provider's IQueryProvider.Execute() or IQueryProvider.CreateQuery() methods are called with an Expression passed to it, and then either a query result or another IQueryable is returned, respectively.
Source: Link
Posted Jun 13, 2011, 9:04 PM EDT
The primary difference is that the extension methods defined for IQueryable take Expression objects instead of Functional objects, meaning the delegate it receives is an expression tree instead of a method to invoke.
IEnumerable is great for working with in-memory collections, but IQueryable allows for a remote data source, like a database or web service.
IEnumerable doesn't have the concept of moving between items, it is a forward only collection. It's very minimalistic; something that most any data source can provide. Using only this minimal functionality, LINQ can provide all of these great operators.
IQueryable is a very powerful feature that enables a variety of interesting deferred execution scenarios (like paging and composition based queries).
Hope this helps !!!
Sourcehttp://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/
Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 13, 2011, 9:04 PM EDT