Answer the question
In order to leave comments, you need to log in
How does lazy loading work?
How does Lazy Loading work?
I read that at the first access to the entity, the loading of related objects is not performed, what does it mean on the first access?
But when accessing the navigation property does - what does accessing the navigation property mean? And also where is the download performed - in the cache? And how is the information removed - is it removed after accessing it? What happens where how
There are also Eager and Explicit download methods. For example, I do not want to use Lazy loading at some point, but I want Explicit loading - is this possible?
And now small working questions: How in each of cases to address in the bound parameters? It is not very easy to find detailed and understandable instructions.
And also the question arises of how this all affects the data model and the database in each of the loading methods?
_____
Answer the question
In order to leave comments, you need to log in
Judging by the question, you mean the Entity Framework? There is a great article
on
lazy loading by Julia Lerman from '11. Although the article is quite old, it is relevant. Here is a brief example of using the technology, and here is the official description.
In general terms, Lazy Loading works by creating proxy classes on top of your code, which provides a call to loading methods - a kind of dependency injection implementation.
Linked entities are loaded by accessing the navigation property (default behavior), but you can tell the framework to load linked entities directly with the Include method.
A navigation property is a property of a type or list of a type such that the type is another entity in the same data model.
Lazy loading can be directly disabled in the context constructor, or direct loading can be specified using the Include method as described earlier.
The data model is not affected by the loading method other than the creation of proxy classes.
Entities are accessed transparently, through the "." operator, as if they were properties of an object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question