Welcome to Bilal Haidar [MVP, MCT] Official Blog Sign in | Join | Help

Is Deferred Execution always required and needed

In the previous post, I have explained the idea behind Deferred Execution. What if you wanted to directly execute the query expression and bind the results to a GridView or any other Data Control? In this case, Deferred Execution is not required. The solution is simply using one of the methods defined on the Sequence class:

1. ToArray();
2. ToList();

and now the previous query expression is as follows:

var getCustomers= (from c in db.Customers
                             select c).ToList();

We don't have Deferred Execution anymore and the getCustomers now include all the records.

Hope this helps,
Regards

Published Wednesday, July 25, 2007 12:08 PM by BilalHaidar [MVP]
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required)