I am using the below code and trying to group by Currency and Code. After this I am trying to loop through the result set.
But the issue is while looping through the
This:
amount = grp.Sum(x => Convert.ToDouble(x["AMOUNT"]))
will not work as you expect. If x["AMOUNT"] is DBNull.Value instead of a valid double, the conversion will fail with an exception. Instead, try:
amount = grp.Sum(x.Field("AMOUNT"))
if you expect that field to be a double. Sum will treat the null values as zero, per MSDN.