What is the difference between IQueryable<T> and IEnumerable<T> interface?

 Posted by Raja on 5/11/2010 | Category: C# Interview questions | Views: 12053

IEnumerable<T> is best suitable for working with in-memory collection.
IEnumerable<T> doesn't move between items, it is forward only collection.

IQueryable<T> best suits for remote data source, like a database or web service.
IQueryable<T> is a very powerful feature that enables a variety of interesting deferred execution scenarios (like paging and composition based queries).

So when you have to simply iterate through the in-memory collection, use IEnumerable<T>, if you need to do any manipulation with the collection like Dataset and other data sources, use IQueryable<T>.

Please let me know your feedback, if any

| Alert Moderator 

Comments or Responses

Login to post response