IQueryable Vs IEnumerable - Jinal Desai

5,238 views

Published on

IQueryable inherited IEnumerable, so it obviously get all the functionality IEnumerable has. The working style of both is still different. There are still lot many differences exists between the two which impact the decision we took in usage of either one. Both of these suits for particular scenarios. Following are some differences using which we can took decision to use anyone of these optimally.

Published in: Technology
  • Be the first to comment

IQueryable Vs IEnumerable - Jinal Desai

  1. 1. Articles from Jinal DesaiIQueryable Vs IEnumerable2012-05-06 10:05:03 Jinal DesaiIQueryable inherited IEnumerable, so it obviously get all the functionality IEnumerable has. The workingstyle of both is still different. There are still lot many differences exists between the two which impact thedecision we took in usage of either one. Both of these suits for particular scenarios. Following are somedifferences using which we can took decision to use anyone of these optimally. Parameter IQueryable IEnumerable Extension methods defined for Extension methods defined for IQueryable take IEnumerable take functional objects.Extension expression objects. Means, the delegate Means, the delegate IEnumerableMethods IQueryable extension methods receives is an extension methods receives is a method expression tree. to invoke. IQueryable allows out-of-memory things like IEnumerable is great for working withGreat For remote data source operations, such as sequences (in-memory collections), that working with database or web service. are iterated in-memory.Supported IEnumerable supports LINQ to Object IQueryable supports LINQ to SQL queries.Queries and LINQ to XML queries. IQueryable supports lazy loading (Suited forDeferred IEnumerable lost lazy loadnig ability on scenarios like paging and composition basedExecution the external provider. queries).Moving IEnumerable doesn’t have the concept of IQueryable provides many methods to movebetween moving between items, it is forward only between the items.items collection. IEnumerable executes select query onFiltering IQueryable executes query on server side along server side, loads data in-memory andMechanism with all the filters applied. then executes filter at client side. IQueryable has these two additional methods.CreateQuery Both takes expression as input. CreateQueryand Execute NA returns IQueryable representing expressionMethods tree. Execute returns result of the query.Custom IQueryable provides additional functionality to IEnumerable does not have customQuerying implement custom querying with LINQ. querying capability.Capability IQueryable gives best performance when used IEnumerable gives best performancePerformance for out-of-memory data store operations (that is when used to manipulate in-memoryPerspective external to .NET CLR memory). collections.Referenceshttp://stackoverflow.com/questions/252785/what-is-the-difference-between-iqueryablet-and-ienumerablethttp://blogs.msdn.com/b/erickt/archive/2006/10/23/iqueryable-t-vs-ienumerable-t.aspxhttp://www.codeproject.com/Articles/231163/IQueryable-Vs-IEnumerable-in-terms-of-LINQ-to-SQLhttp://forums.asp.net/t/1761294.aspx/1http://stackoverflow.com/questions/7606633/net-entity-framework-ienumerable-vs-iqueryablehttp://michaelmairegger.wordpress.com/2011/08/07/ienumerable-vs-iqueryable/http://ramanisandeep.net/2009/08/26/iqueryable-vs-ienumerable/http://blogs.msdn.com/b/wriju/archive/2008/05/06/linq-ienumerable-t-and-iqueryable-t.aspxhttp://www.shawnmclean.com/blog/2011/06/iqueryable-vs-ienumerable-in-the-repository-pattern/http://www.c-sharpcorner.com/Forums/Thread/127203/what-is-the-use-of-iqueryable-in-the-context-of-linq.aspxhttp://stackoverflow.com/questions/2433306/whats-the-difference-between-iqueryable-and-ienumerable
  2. 2. Blog this!Bookmark on DeliciousDigg this postRecommend on FacebookShare on FriendFeedShare on LinkedinShare on Orkutshare via RedditShare with StumblersShare on technoratiTweet about itSubscribe to the comments on this post

×