Delayed loading, delayed loading and accelerated loading in Entity infrastructure

What is the difference between these three types of downloads? Can someone explain an example? Different resources on the Internet use different definitions, causing more confusion than necessary.

+6
orm entity-framework entity-framework-4
source share
3 answers

Lazy loading and Deferred are pretty synonymous (AFAIK, please correct me if I am wrong). The big difference between Eager and Lazy. The wait will come in front, Lazy will only happen “as needed”, and execution will be done at the DB level - let’s take a simple JOIN as an example

var people = (from p in people SELECT p).ToList(); var jobs = (from j in jobs SELECT j).ToList(); var peopleAndJobs = (from p in people JOIN j on j.personId equals p.personId SELECT p).ToList() 

This is an example of heavy loading. We get ALL people, ALL work, and we do the unification in memory. Not very smart (usually). This is what the Lazy style looks like.

 var people = (from p in people SELECT p); var jobs = (from j in jobs SELECT j); var peopleAndJobs = (from p in people JOIN j on j.personId equals p.personId SELECT p).ToList() 

This makes the creation of IQueryable for people and for work (IQueryable is lazy), and the connection occurs in the database. This saves network activity and usually works faster because the database is optimized for consolidation, etc.

If we don’t say directly: “I need this data!” (by ToList it, iterating through it, etc.), he is lazy. There are a few other quirks, but this should be a decent tutorial.

+7
source share

Lazy / Deferred Loading : Lazy loading and delayed loading are the same. The connection is loaded the first time you access it. The idea is that if data is not required, it should not be downloaded.

Lively download . Relationships are taken with the parent. This may be more efficient when loading data, but will load data regardless of the data used / not used.

+3
source share

When objects are returned by a query, related objects are not loaded at the same time.

Instead, they automatically load when accessing the navigation properties. Also known as lazy loading,

0
source share

All Articles