By default, LINQ uses deferred query execution, means when you declare or write a LINQ query it doesn't execute. LINQ queries execute when you we use the query results.
//Query doesn’t execute here
var query = from designation inSampleDbContext.Designation
where designation.Title == "Software Engineer"
// Query executes here
foreach (var designation in query)
Deferred execution advantages:
1. The main benefit is that deferred query execution allows filtering operations with some in LINQ query itself.
2. It avoids unnecessary query execution reason it improves performance.
3. Query construction and Query execution are decoupled, so we can create the LINQ query in several steps.
4. A deferred execution query is reevaluated when you re-enumerate – hence we always get the latest data.
Some advantages I added using following reference