In Entity Framework 4, what is the difference between Lazy Loading, and using Load() method?
Edit: I have added, two 'if' statements:
Lazy Loading:
var query = from c in context.Contacts select c;
foreach ( var contact in query ) {
if ( contact.ID == 5 )
Console.WriteLine( contact.Addresses.City );
}
Load() method:
context.ContextOptions.LazyLoadingEnabled = false;
var query = from c in context.Contacts select c;
foreach ( var contact in query ) {
if ( contact.ID == 5 ) {
contact.Addresses.Load()
Console.WriteLine( contact.Addresses.City );
}
}
Now, having this two 'if' checks, why should I preffer one before another?