February 2010
Beginner
400 pages
11h 13m
English
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;
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 ...