'Should we use MediatR + Services + Repositories?
We're using MediatR and inside the Handlers we directly call the Repositories to get/add/delete data. Should we always create a Service that calls the Repositories instead?
Solution 1:[1]
You can safely use repository in handlers, you don't need to create another layer (service).
MediatR
1.) Get, GetAll ,GetByCondition ... (all get calls)
Controller -> Queries (Queries layer) -> Repository
2.) Add/Update/Delete
Controller -> CommandHandlers (handlers layer) -> Repository
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Areg Gevorgyan |