Calculated Properties in Odata v4 and Entity Framework

末鹿安然 提交于 2021-01-29 04:24:34

问题


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.

I have tried [notmapped] attribute. But it hides the property in Odata $medadata.

How can I overcome this issue?


回答1:


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

Hope it can help.



来源:https://stackoverflow.com/questions/31191013/calculated-properties-in-odata-v4-and-entity-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!