Pergunta

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.

Foi útil?

Solução

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

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top