How to get ODATA to serialize NotMapped property
|Added at||2017-01-05 19:01|
I have a WebAPI backend that provides inventory information, etc. to various clients, using ODATA v3 (I cannot use v4 due to a restriction in a component that we use). The inventory database is quite large (100K+ records) and ODATA is great for server-side filtering, pagination, etc. and keeping the data transfers lean.
The inventory records have some properties that are not mapped, but rather calculated and populated on the fly as the queries are made. For example:
The problem is that ODATA ignores any NotMapped properties, so they never get sent back to the clients.
I know this has been asked before, but that was a while ago now so I was hoping that support for this has been added by now or that somebody has a simple workaround (short of letting EF create these fields in the DB).
I have tried this ugly workaround, but it did not work (RebateAmount still does not get included by ODATA):
Is there a (preferably simple) way to include non-DB properties in ODATA result sets?
Edit 1/7/2017 For this to be useful in my scenario, ODATA needs to also include the calculated fields in its metadata, otherwise the auto-generated (client-side) proxy classes will not include them.