Imagine we have two entities, EntityA and EntityB. Both entities have a repository to query the database, EntityARepository and EntityBRepository. There are also services for both of them, EntityAService and EntityBService.
Now there is a method in the EntityBService, which also needs to use EntityA. What would be the right way of doing this?
- Should the
EntityBServiceuse theEntityARepositorydirectly? - Should the
EntityBServiceuse theEntityAService?
I could see how using the repository directly might be very convenient, but also it seems to get kind of messy when having not only two entities.
Is there common design pattern around this topic or recommendations?