I have a WebAPI backend that provides inventory information, etc. to different clients using ODATA v3 (I cannot use v4 due to the limitation in the component we use). The inventory database is quite large (100K + records), and ODATA is great for server-side filtering, pagination, etc. And save data transfer.
There are some properties in inventory records that are not displayed, but rather are computed and populated on the fly when queries are executed. For instance:
[NotMapped] public decimal RebateAmount { get; set; }
The problem is that ODATA ignores any NotMapped properties, so they are never sent back to clients.
I know that this was asked earlier, but it was a long time ago, so I was hoping that support for this was added by now or that someone has a simple workaround (if you do not allow EF to create these fields in the database).
I tried this ugly workaround but it didn't work (RebateAmount is still not included in ODATA):
private decimal _rebateAmount; public decimal RebateAmount { get {return _rebateAmount; } } public void SetRebateAmount(decimal amount) { _rebateAmount = amount; }
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 must also include calculated fields in its metadata, otherwise automatically generated (client) proxy classes will not include them.
source share