Odata v4和实体框架中的计算属性 [英] Calculated Properties in Odata v4 and Entity Framework
本文介绍了Odata v4和实体框架中的计算属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理.Net Web Api 2.2项目,并且首先使用Odata v4和Entity Framework代码.我需要在模型中具有一个已计算的属性,该属性不能保存在数据库中.
Im working on a .Net Web Api 2.2 project and I'm using Odata v4 and Entity Framework code first. I need to have a calculated property in a Model which is not to be saved in Database.
我尝试了 [notmapped]
属性.但这会将属性隐藏在Odata $ medadata中.
I have tried [notmapped]
attribute. But it hides the property in Odata $medadata.
我该如何克服这个问题?
How can I overcome this issue?
推荐答案
您可以手动将此属性添加到模型中.
You can manually add this property into model.
You can refer to the sample codes in: How to get Web API OData v4 to use DateTime
希望它可以提供帮助.
这篇关于Odata v4和实体框架中的计算属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文