confusion in the Lazy loading, Deferred Loading .are they same or different?what is eager l开发者_如何学Pythonoading.can any one explain me with example.
These terms have been thrown around quite a bit in different contexts and the first two are often used interchangeably - here's my take:
Lazy loading - Often used to mean a navigation property on-demand (e.g. thisOrder.Customer will only load the customer when you access it).
Deferred loading - You can set a regular property (e.g. Customer.Notes) to defer loading (in the designer). It then isn't loaded with the Customer object but is loaded on-demand in much the same way as lazy loading.
Eager loading - If you know you definitely want navigation properties (or even deferred properties) you can tell LINQ to SQL to get them at the same time using DataContext's LoadOptions. This will switch from being 1 query then 1+ query per entity returned in the first query (SELECT N+1 problem) by generating a join.
I don't know if you have found your answer but, I was also looking to see the difference between these and i found a nice little article by Nikolaos Kantzelis about Lazy Loading,Eager Loading,Explicit Loading in Entity Framework 4:
http://weblogs.asp.net/dotnetstories/archive/2011/03/10/lazy-loading-eager-loading-explicit-loading-in-entity-framework-4.aspx
https://github.com/jakubmaguza/Lazy-vs-Deferred-vs-Normal
Here you can find differences. Just download or copy-paste code from file and press start. You will see output like this:
Debuging application will also be helpful.
精彩评论