-2

Possible Duplicate:
What is the difference between IQueryable<T> and IEnumerable<T>?

I read so much about IQueryable and I still dont understand when to use what and what are IQueryableProvider's methods used for.

My english isnt perfect so understanding that article is imposibol for me. http://blogs.msdn.com/b/mattwar/archive/2007/07/30/linq-building-an-iqueryable-provider-part-i.aspx

*Do not tell me to use IEnumerable for collections and IQueryable for sql becouse we can use each one to collections and sql.

Community
  • 1
  • 1
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
  • *Do not tell me to use IEnumerable for collections and IQueryable for sql becouse we can use each one to collections and sql. -->> thats the answer they give him.. – Stav Alfi Oct 06 '12 at 09:17
  • 1
    @StavAlfi, with IEnumerable you'll load the WHOLE SQL TABLE in RAM and go over it. With IQueryable an SQL query will be generated. That is the difference and an extremely important one. – CMircea Oct 06 '12 at 09:27

2 Answers2

3

An IEnumerable is near enough the simplest interface for a collection that can be iterated over, like in a foreach loop.

An IQueryable is a query builder that holds a LINQ query that can be added to until you do something with the query that forces it to execute and return a collection.

Adrian Thompson Phillips
  • 6,893
  • 6
  • 38
  • 69
1

IQueriable Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified. whilst the IEnumerable only allows a way to cycle over them.

So, in summary,

Queryable lets you interigate the data

Enumerable lets you go through each element of the data