'IEnumerable<object>' does not contain a definition for 'Sum'


Hi everyone,

I am hoping someone can help me with the snippet of code below. I cannot get the .Sum() to work with my UD field ‘weight’. I am not actually using the line above this one but have inserted it to show that the .Sum() works there. I think it’s a syntax error on my part but I cannot work out how to write it correctly.

Thanks for any help

Give this a shot and see if it works.

var weight = quoteTS.QuoteDtl.Where(row => Convert.ToDecimal(row["totalWeight"]) > 0).Select(QD => Convert.ToDecimal(QD["totalWeight"])).DefaultIfEmpty(0).Sum() ;
1 Like

Thanks Brandon, that worked. Sometimes it just needs another pair of eyes :face_with_monocle:


1 Like

I happened to have a BPM loaded up into visual studio (it’s a pain to set up…) so I was able to use visual studio to help me out to play with it.