and choice IEnumerable<T>
IQueryable<T>
When using linq query, select
will have a significant impact on performance and data retrieval. These two interfaces are different in processing the delayed execution, which allows optimization and efficient processing of data query. IEnumerable<T>
IQueryable<T>
Delayed execution: critical differences
and both support delayed execution, which means that the query will not be executed immediately when it is created. Instead, the query is expressed as an expression that can be performed in the future. However, there is a key difference between each interface processing delay execution.
IQueryable<T>
: Database is not related to the query IEnumerable<T>
is an interface that enables the Linq to SQL query, which allows high -level operations to perform data sources without having to understand the underlying database. When performing inquiries with , the query provider (for Linq to SQL, this is a database engine) to convert the query and convert to optimized SQL statements.
IQueryable<T>
This optimized SQL statement runs on the database server, and only returns the result of matching the query conditions. If further refinement is needed, the new query will also be executed on the database, so as to maintain high performance and optimization level.
: Operation in memory IQueryable<T>
IQueryable<T>
Select the correct options
IEnumerable<T>
The choice of and depends on the specific requirements of the application.
IQueryable<T>
IEnumerable<T>
Inquiry involved in the screening and processing in memory The above is the detailed content of IEnumerable vs. IQueryable: When Should I Choose Which?. For more information, please follow other related articles on the PHP Chinese website!