Let's say I have two services on my service, ServiceA and ServiceB , each of which has an interface ( IServiceA and IServiceB respectively).
The user interface layer contains links to service interfaces that return DTOs from their methods. Specific service classes are responsible for mapping domain models (EF POCOs) to DTOs.
ServiceA accepts a dependency on IServiceB through dependency injection, using the IoC container to invoke some methods of this service.
This raises several problems:
An unnecessary / duplicate mapping to and from the DTO only to invoke the method and / or use the result.
Tight binding of the invocation method with DTO contracts of the input parameters of the invoked methods and the type of the return value.
At first, I decided to reorganize the logic into an internal method and call it from both services. However, since ServiceA accepts a dependency on the IServiceB interface, internal methods are not displayed.
How would you deal with this problem?
Additional information (added sample code on request):
source share