Consume repository of entities directly from the application layer

5

I have a scenario that I need to fetch a list of Active Employees with Entity Framework and display them on the screen (I need to convert to DTOs before displaying - which I do by the Application layer).

For a Domain-Driven Design (DDD) scenario, there are Application , Domain layers, and Infra ... I am in doubt in this scope. Domain services are created when logic matters to the domain, right? So I could fetch this list directly between Application and Repository , in this way, without creating a service on the Domain layer? Of course, getting a list of assets would be just a LINQ filter, I do not know if I can consider this a business rule ... Who can clarify this question for me? Thank you.

    
asked by anonymous 13.02.2017 / 00:57

1 answer

3

In DDD, the Application layer knows how to consume the Domain layer objects to meet requests from the above layer ( Interface ). ; and DDD repository is a type of domain object.

Now if the Application layer consumes domain objects and if repository is a domain object type, then there is no need to encapsulate the repository inside a service so that it can be consumed by the application layer.

  

In DDD, the Application layer can consume repositories directly, without the need for these repositories to be encapsulated in another service.

Of course, if after obtaining the entities you still need to run any business logic, this business logic would in fact need to be in a service (which is a domain object type in DDD ) or in the entity .

Note also that the filter you are going to execute on the entities when consuming the repository directly from the application layer needs to be a filter with an API that speaks the language of the experts in the business, since in DDD all the code of the layer domain needs to speak this language.

    
13.02.2017 / 12:47