开发者

Deferred Execution

开发者 https://www.devze.com 2022-12-18 19:49 出处:网络
I would like to know whether la开发者_如何学Czy loading == deferred execution?No. \"Lazy loading\" is typically used to indicate that if you have an instance of an entity with a property that refers

I would like to know whether la开发者_如何学Czy loading == deferred execution?


No.

"Lazy loading" is typically used to indicate that if you have an instance of an entity with a property that refers to some other entity, dereferencing the property in code will cause a database query to be issued to materialize that other entity, if it is not already loaded.

E.g:

var foo = Context.Foos.First();
var bar = foo.Bar; // with lazy loading, this causes a DB query for foo.Bar;

"Deferred execution" is typically used to mean that no database query will be issued at all until an IQueryable is iterated.

E.g.

var foos = context.Foos.Where( f => f.Id == id); // no db query ; deferred
var foo = foos.First(); // now a query is issued.
var count = foos.Count(); // another query is issued


I suspect that you think of "deferred loading" in Entity Framework 4, which is actually the same as lazy loading.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号