简体   繁体   中英

Calculated Properties in Odata v4 and 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.

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

Hope it can help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM