what does "until it's realized value is required" in deferred execution means?

StackOverflow https://stackoverflow.com/questions/21347937

  •  02-10-2022
  •  | 
  •  

سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top