3
votes

I currently have inheritance between DTO's which works well as long as I have for each concrete (leaf-node) DTO a [Route] defined, and not on one of the superclasses. Up until now the superclasses were all abstract. Now I'm in the situation where I have a DTO which is concrete and has a [Route] attribute defined is also a superclass of another DTO with it's own route.

Both DTO's have their own services, but it does not work as expected. Both DTO's are "routed" to the leaf-node.

superclass DTOA
subclass DTOB where DTOB : DTOA

when I do a GET on DTOA it is the service for DTOB that responds. Apart from modeling my inheritance different, how can I fix that the routes work as I had hoped they would?

therefore:

DTOA routed to serviceA
DTOB routed to serviceB

Is this happening because of the fact that RouteAttributes are inherited? And what is the reason for having Inherited = true on the RouteAttribute?

1

1 Answers

0
votes

Don't use inheritance in Request DTOs. Inheritance on DTOs are bad idea to begin with, and they should especially be avoided in Request DTO's which should be bespoke for each service.

The Route attribute can be applied on Services and/or Request DTOs and supports the New API and the Old API which allows inheritance.