Typed Service Methods

We call services from within other services.

When we use the C# client we get typed responses.

But since in this case we are in the same app we want to call them directly.

If we call a method on a service that we Resolve inside other service the return type is object:

using (var service = ResolveService<WikisService>())
    var res = service.Post(new CreateWiki());

Is there any shortcoming in returning typed responses in our service methods (instead of object)?

I think I had some issues with this approach in the past, while using the ToOptimizedResultUsingCache extension method.


No there’s no short-coming other than not being able to return a normal typed response and a decorated typed response (e.g. inside HttpResult) from the same method.

I’ll prefer to add the Response Type on the Request DTO with IReturn<TResponseType> since it also benefits clients, but when I’m making inter-service calls I’ll often change object to the concrete Response Type to be able to access a typed API internally.