.net - 动作绑定忽略继承的属性 (API)
问题描述
[ResponseType(typeof(PlanningRestGet))]
public HttpResponseMessage Put(int id, [FromBody] PlanningRestPut model)
{
return CallAndPrepareResponse(c => c.UpdatePlanning(id, model));
}
我创建了一个具有两个新属性的新“BaseRestPut”类,并使 PlanningRestPut 类继承它。
但是现在当执行动作时,来自基类的属性在模型对象中为空。
我已阅读此https://www.tutorialdocs.com/article/webapi-data-binding.html但在我的情况下,我不想将基类作为参数传递,而是派生类(并保留基类的属性。)
我怎样才能做到这一点?
解决方案
这是因为我的基类缺少 [DataContract] 装饰器。
推荐阅读
- angular - 空结果的角度“包含”
- laravel - 对同一列中具有相同值的行进行分组
- splunk - Splunk:使用 spath 和 groupby 的嵌套字段的 tstat 计数不返回结果
- java - 在 OkHttp 中等效的 setEntity - Android
- python - 尽管我尽了最大努力,但 'Googlechrome' 不在 PATH 上
- python - 开箱并增加值
- angular - 如何让离子原生诊断 checkLocation isEnabled() 在我的应用程序中一直工作?
- java - 是否可以从 Java 中的配置文件初始化静态最终变量?
- javascript - JavaScript 函数调用返回未定义,为什么?
- c# - INotify 接口未更新我的 XAML 接口