Thursday, September 13, 2012

IQueryable and IEnumerable

IEnumerable helps to iterate in the collection or list objects as well known.

IQueryable is an interface and also has extension methods one among which is "AsEnumerable".
"AsEnumerable" method returns IEnumerable object.

IQueryable holds expression and return element type beside IEnumerable.

While calling "AsEnumerable" extension method, the expression is evaluated and the result can be enumerable.

So while calling extension methods after "AsEnumerable", they work on the final collection or list (In Memory).

Where as while calling extension methods of "IQueryable", they work on ahead before getting the list.
This could be the case while working on remote data object or database, it would help to apply where or order by clauses ahead on the data using extension methods before getting in memory list (IEnumerable).

No comments:

Post a Comment