gpt4 book ai didi

servicestack - RouteAttribute, AttributeUsage, Inherited = true

转载 作者:行者123 更新时间:2023-12-04 03:58:51 26 4
gpt4 key购买 nike

我目前在 DTO 之间有继承,只要我为每个具体(叶节点)DTO 定义了一个 [Route],而不是在某个父类(super class)上,它就可以很好地工作。到目前为止,父类(super class)都是抽象的。现在我的情况是,我有一个具体的 DTO,并且定义了一个 [Route] 属性,它也是另一个具有自己路由的 DTO 的父类(super class)。

两个 DTO 都有自己的服务,但不能按预期工作。两个 DTO 都“路由”到叶节点。

superclass DTOA
subclass DTOB where DTOB : DTOA

当我在 DTOA 上执行 GET 时,响应的是 DTOB 的服务。除了对我的继承进行不同的建模之外,我怎样才能修复路由按我希望的那样工作?

所以:
DTOA routed to serviceA
DTOB routed to serviceB

发生这种情况是因为 RouteAttributes 是继承的吗? RouteAttribute 上有 Inherited = true 的原因是什么?

最佳答案

不要在请求 DTO 中使用继承。 Inheritance on DTOs are bad idea首先,在为每项服务定制的请求 DTO 中应特别避免使用它们。

Route 属性可应用于服务和/或请求 DTO,并支持 New API以及允许继承的旧 API。

关于servicestack - RouteAttribute, AttributeUsage, Inherited = true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14626235/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com