Answer the question
In order to leave comments, you need to log in
How to load nested entities in ddd?
I’ll point out right away that ddd doesn’t seem to have any exact implementation instructions. I implement in my own way, based on the needs.
I have entities and repositories for them. In my view, an entity can change its properties and properties of nested entities, as well as load nested entities using their repositories. The problem with such a load is that in the case of creating a list of entities, each of them must load its data, when it would be possible to load the data for all at once with 1 request. This prompted the need for services. It is planned that the service will have a method-command of the loadOrdersForPaymentPage type that will load both entities and nestings in them, and return a ready-made list.
Service example .
Evans quote about services.
When a significant process or transformation in the domain is not a natural responsibility of an ENTITY or VALUE OBJECT, add an operation to the model as standalone interface declared as a SERVICE. Define the interface in terms of the language of the model and make sure the operation name is part of the UBIQUITOUS LANGUAGE. Make the SERVICE stateless .
Answer the question
In order to leave comments, you need to log in
I have entities and repositories for them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question