I have a database column that I am trying to get the sum for every record. In my test sample I am only returning 6 records
My column is called WageAmount. I have tried everything and my decimal shows a value of 0. The statement returns no row with a null value.
convert(decimal(18,2),Sum(PR.WAGE_AMOUNT end)) AS [WageAmount],
In c# my code is
decimal d = 0;
decimal total = dt.AsEnumerable().Where(r => !r.IsNull("WageAmount") && decimal.TryParse(r["WageAmount"].ToString(), out d)).Sum(r => d);
d = 0 and total = 0. What am I doing wrong?
Open in new window