.NET FAQs Unleashed!
 
    
    

What is deferred execution in LINQ?

Deferred execution in LINQ is a way through which the queries can be executed at a later stage. In such an approach, an object is first defined that contains the query. This query runs only at a later stage. For example:

var result = from reportcard in dbContext.Class5 where reportcard.studentname = 'Pedro'; //This object result will execute later when used inside a foreach loop.

Here, the query expression only defines the query. The object 'result' returns the actual result. During processing, Entity Framework lets the database do the actual processing by using the database routines. This makes it sure that the performance is at its best. Further, you may even create chained queries in LINQ where a query can query from another query. It is something like a nested statement.

ADO.NET Base Classes   DataSet Advantages   SQL Queries through String Concatenation   Deferred Execution in LINQ   Object LINQ Provider VS. Database LINQ Provider   .edmx file   ADO.NET Entity Framework   Silverlight connections to databases   Multiplicity and Degree in Entity Framework   NHibernate   WCF Data Services   Optimistic Concurrency | OptimisticConcurrencyException   TransactionScope Class   Entity Framework and CRUD   Lazy Loading  

More Interview Questions...