Question : LINQ Aggregated Multiply


The table above is my source table and
the table below is the target view i would like to have.


CalculatedRate calculation starts from the last record to first record within same symbols.
first values are exactly same with rate and after that multiply with previous one

latest XYZ is at 12/10/2010 and rate is 3.81 which sets CalculatedRate as same with Rate which is 3.81
next XYZ is at 9/10/2010 and rate is 1.11 which means we need to multiply it with previous one 1.11*3.81=4.2291
next XYZ is at 6/10/2010 and rate is 2.49 multiply it with previous one 2.49*4.2291=10.530459

P.S.: I need a solution with LINQ

Thank you for your time and atention.

Answer : LINQ Aggregated Multiply

Hi cilerler:

To your last question, "About "Let clause doesn't have access for previous value" that's the whole point of this question, I mean it should have it, since Linq has Aggregate ability.", As I stated in your other question you have and my answer re-posted below it can not be accomplished with the Aggregate method

From Microsoft documentation:
The Aggregate method makes it simple to perform a calculation over a sequence of values. This method works by calling func one time for each element in source. Each time func is called, Aggregate passes both the element from the sequence and an aggregated value (as the first argument to func). The first element of source is used as the initial aggregate value. The result of func replaces the previous aggregated value. Aggregate returns the final result of func.

The Aggregate method works on a sequence from beginning to end and returns a single value. This is the same for Count, Sum, Min, Max, and Average methods so will not serve your needs.

Random Solutions  
programming4us programming4us