What's the difference between IList, IEnumerable, and IQueryable?
-
I was asked that yesterday and didn't really know. It's always interesting to discover where my knowledge gaps are. Great article[^] on it right here on CP! Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
-
I was asked that yesterday and didn't really know. It's always interesting to discover where my knowledge gaps are. Great article[^] on it right here on CP! Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
I deal pretty heavily with these interfaces internally - most of my cache collections, for instance, return IEnumerable of the appropriate type.
This space for rent
-
I was asked that yesterday and didn't really know. It's always interesting to discover where my knowledge gaps are. Great article[^] on it right here on CP! Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
I didn't think it was very good actually, it didn't show a great understanding of those interfaces and contained a fair amount of incorrect information and bad advice (eg using IEnumerable is bad for memory use as it brings back all records is the exact opposite of the truth). The author was making assumptions about the interfaces and their uses from SQL Profile traces from Entity Framework
-
I didn't think it was very good actually, it didn't show a great understanding of those interfaces and contained a fair amount of incorrect information and bad advice (eg using IEnumerable is bad for memory use as it brings back all records is the exact opposite of the truth). The author was making assumptions about the interfaces and their uses from SQL Profile traces from Entity Framework
He lost a big chunk of upfront credibility in suggesting the use of the .net 1.x non-generic ArrayList and HashTable in some circumstances. Both types should have been moved to the
System.Legacy.Cluster.Elephant.Do.Not.Ever.Use
namespace eleven years ago when generics were added.Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
I didn't think it was very good actually, it didn't show a great understanding of those interfaces and contained a fair amount of incorrect information and bad advice (eg using IEnumerable is bad for memory use as it brings back all records is the exact opposite of the truth). The author was making assumptions about the interfaces and their uses from SQL Profile traces from Entity Framework
Ah. I briefly perused the messages, people seemed to have really liked the article, so I didn't see anything from the comments that indicated issues, but thanks for pointing that out. Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
-
Ah. I briefly perused the messages, people seemed to have really liked the article, so I didn't see anything from the comments that indicated issues, but thanks for pointing that out. Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
You might want to edit your original comment and replace the word "great" with "okay" :-)
Regards, Nish
Website: www.voidnish.com Blog: voidnish.wordpress.com
-
I was asked that yesterday and didn't really know. It's always interesting to discover where my knowledge gaps are. Great article[^] on it right here on CP! Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
TLDR version: IEnumerable - supported by any sensible collection. Allows forward-only iteration. IList - provides further members - allows random access, and supports mutation operations. IQueryable - variant of IEnumerable designed to support deferred execution in LINQ. (Edit - just actually read the TLDR, and I must say I was more accurate too).
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.