First I use the framework code 4.1. And I have a classic pattern: Order and OrderLines. Each OrderLine has its own price, and I would like to have the TotalPrice on Order property.
Now I'm not sure to declare a TotalPrice property. I can define it as readonly with the sum of linq, but when every time I add it to the result set, it must extract all order lines from db to sum them up.
I am thinking of a solution that stores totalprice in the database (for queries) and is only recalculated until the order is saved (or if the order line changes), but I do not.
How to handle scripts like this in EF?
Thanks for the suggestions of Petr
source
share