Differences between

IQueryable Inherited from IEnumerable

IEnumerable:IEnumerable<T> Generic classes are calling their own SKip and Take
The data will be loaded in the local memory before some extension methods , All for IEnumerable Filtering of , Sorting and other operations , It's all in memory .

Is to translate these method expressions into T-SQL Back again SQL Server sends command , It does not load all data into memory for conditional filtering ,IQueryable The advantage is that it has an expression tree , All for IQueryable Filtering of , Sorting and other operations , Will be cached in the expression tree first , Only when real traversal happens , The expression tree will be IQueryProvider Perform get data operation ( Analytic expression , Then execute to get results ).


Use environment

Usually in the data access layer
use IQueryable, Because it can delay the loading of data to the business logic layer , Many times , Business logic layer does not need to load data immediately , Business logic layer can still use delay loading , When it's really necessary to load data , Can be converted to IEnumerable