RouteAttribute, AttributeUsage, Inherited = true

I currently have inheritance between DTOs which works well if I have a [Route] DTO for each leaf-node and not on one of the superclasses. Until now, superclasses have been abstract. Now I'm in a situation where I have a DTO that is specific and has a specific [Route] attribute, is also a superclass of another DTO with its own route.

Both DTOs have their own services, but they don't work as expected. Both DTOs are "routed" to a leaf - node.

superclass DTOA
subclass DTOB where DTOB : DTOA

      

when I do a GET on a DTOA it responds to the DTOB service. Aside from modeling my inheritance differently, how can I fix that the routes work the way I hoped they would?

so:

DTOA routed to serviceA
DTOB routed to serviceB

      

Is this happening because RouteAttributes are inherited? And what is the reason why Inherited = true in the RouteAttribute?

+3


source to share


1 answer


Don't use inheritance in the request DTO. DTO inheritance is a bad idea and should especially be avoided in a DTO request that must be custom made for each service.



The Route attribute can be applied to services and / or DTO requests and supports the New API and the Old API that allows inheritance.

0


source







All Articles