Entity Framework Core Interview Question #134
What is query compilation in EF Core?
Performance, Raw SQL, Stored Procedures & Advanced Queries Senior Advanced
Quick Interview Answer
EF Core processes a LINQ expression tree into a database command representation before execution. It automatically caches query compilation information for recurring query shapes. This built-in behavior is sufficient for most applications. Database execution, network I/O, indexing, and materialization are usually larger performance factors than compilation.
Detailed Explanation
EF Core processes a LINQ expression tree into a database command representation before execution. It automatically caches query compilation information for recurring query shapes. This built-in behavior is sufficient for most applications. Database execution, network I/O, indexing, and materialization are usually larger performance factors than compilation.
Code Example
var query = db.Products
.Where(p => p.IsPublished && p.Price > minPrice);