Frage

I'm just wondering. And been looking in Deferred Execution. It says here http://msdn.microsoft.com/en-us/library/bb943859.aspx that Deferred execution means that the evaluation of an expression is delayed until its realized value is actually required.

What does "Until its realized value is actually required" means? Are there methods or property for the value to be realized? Just like the .ToList()

Hope you get what I'm pointing on.

War es hilfreich?

Lösung

Deferred execution is used to mean that no database query will be fired until an IQueryable is iterated.

Let say.

    var employees = db.Employees.Where(x=>x.FirstName == "Krish"); //No query issued
var count = employees.Count(); // now a query is issued

Andere Tipps

Execution of the query is delayed until the query is actually enumerated. A foreach loop or calling .ToList() will force the query to be executed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top