I would like to store a "calculated field" in a Cosmos document.
For example, I would like to store CostGross to be used in reporting, but EFCore should be responsible for sending the value in inserts/updates:
public class OrderItem
{
public decimal CostNet { get; set; }
public decimal CostVat { get; set; }
public decimal CostGross => CostNet + CostVat;
}
expected document in Cosmos (trimmed for brevity):
{
...
"CostNet": 1,
"CostVat": 0.2,
"CostGross": 1.2
...
}
actual document in Cosmos (trimmed for brevity):
{
...
"CostNet": 1,
"CostVat": 0.2
...
}
Is it possible to use EF to map a field so that the read only property appears in the document, meaning that the value doesn't have to be re-calculated by other clients doing a read operation?
Thanks