Lazy Loading:
Advantages:
Load data only when you need it, without planning ahead, avoiding inefficiencies associated with complex external joins, indexes, and view operations
How to use:
First:
With virtual, the type of the property can be the collection type of the task icolooct<t> or 0, 1..1 associated property, before the deferred loaded property is required
Such as: public virtual list<product> products {Get;set;}
Second:
To turn on lazy loading in the context Builder
Contextoptions.lazylodingenabled = true;
Disadvantages:
multiple interactions with the database, reduced performance
To prevent a deferred load solution:
Tolist (), the returned thing is a memory-level object, that is, forcing it to execute a SQL statement here, the query into the Web server memory, where the effect of the cache, which prevents the lazy loading
Lazy loading and greedy loading in EF