Access to aggregated objects without lazy loading

I want to follow the DDD philosophy, and not directly access the objects of aggregate objects. So, I have to call the root object to get the related object. But in other cases, I do not always want each associated object to load when the root is called. Is this the goal of lazy loading?

How can I access object objects through the root directory without loading all related objects every time I turn off the lazyloading linq function?

EDIT:

For example, if I have a Face as a Root Being, and a Man has a Name, Addresses and Own properties. If I want to get a list of people so that I can display their names, I don’t have to download Custom properties every time I call to the repository. Conversely, on another page, I can display the OwnedProperties list, but I do not want other information to be loaded when called. What is a simple way to simply invoke a Person without an object of ownership, except creating an object of a new person without these properties?

+3
source share
3 answers

I do not think this is possible without lazy loading.

  • Getting all data at once: Eager Loading
  • Access data retrieval: lazy loading
+1

: , , - "" "DTO", , . , PersonView, Name.

, OR/M mapper ( NHibernate), HQL ( Criteria), Person. NHibernate, , PersonView ( ). NHibernate , , , PersonView.

+1

- 'id'

0

Source: https://habr.com/ru/post/1706564/


All Articles