Deferred Execution
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.
精彩评论