I am trying to understand difference between IQueryable, ICollection, IList & IDictionary interface which is more faster for basic operations like iterating, Indexing, Q
IQueryable,IList,IDictionary,ICollection inherits IEnumerable Interface. All the interfaces of type collection will inherits IEnumerable Interface.
Differences Between IEnumerable and IQueryable IEnumerable:-when you are running a query which returns of type IEnumerable. IEnumerable will first Executes the first query and then executes the sub queries written for that query.
Example:-If you want get the top 10 population Records from a Particular country then the query we will use in LinQ is
IEnumerable _Population=from s in India select s.population;//First Query _Population=_Population.take(10);//Second Query
Now if we execute this query First Query will be executed first the IEnumerable will get the Records of all the population from the sql server then it will store the data in the In Process memory and then it executes the top 10 population in the next Query.(Execution is taken place for two times on sql server).
if we execute the same query by using IQueryable .
IQueryable _Population=from s in India select s.population;//First Query _Population=_Population.take(10);//Second Query
in this IQueryable it will execute the two Queries at the same time in the sense it will get the population which is of top 10 in a single Query instead of getting the data and filtering the first 10 again.(One time execution on sql server).
Conclusion for IQueryable and IEnumerable