I am trying to calculate depreciation values using values from the database and display in a grid.
The table has 3 columns. Id, DepreciationRate, DateDepreciated. To get the opening value, I pull the cost from another table. My issue is how to calculate and display each depreciation using only the rate. We would store the new value but depreciations can delete or added for different dates.
Ex. We have an item that cost $10 and add a depreciation that is 10%. The new value is $9. We add 2 more depreciation’s at 5% each, making the value $8.12. We then remove the one of the 5% depreciation’s so the value should now display as $8.55.
One of the columns in the grid will show the value before depreciation.
Is there anyway to calculate the new value in LINQ? Maybe Aggregate?
I am using VB.net with LINQ to SQL
If I get your drift try the following:
Alternatively if that is taking a long time one could try doing the join itself in local memory: