8.11. Deferred/Lazy Loading
Lazy loading is a coding technique that minimizes resource usage and database access by not loading an entity until it is actually accessed. In EF4, lazy loading is switched on by default. If you want to turn lazy loading off, then set the ContextOptions.LazyLoadingEnabled option to false in the context class:
ctx.ContextOptions.LazyLoadingEnabled = false;
8.11.1. Eager Loading
While we are looking at lazy loading, it's worth mentioning its evil twin, eager loading. Eager loading is the exact opposite of lazy loading, and means preloading an entity before you need it. This can increase the responsiveness of your application if the initialization is spread out over your application's lifetime. Julia Lerman has a great ...
Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.