views:

48

answers:

2
+1  Q: 

deferred execution

Hi,

I would like to know whether lazy loading == deferred execution ?

Thanks

Regards

Yong

+2  A: 

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
Craig Stuntz
I was trying to type that (and get it straight in my head at the same time). +1 for fastest fingers :)
Binary Worrier
A: 

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

Luhmann