c# - LINQ Syntax for Selecting a Parameter to Be Copied -
i have code sort collection in linq in c#. want group housename sum on volumes, order collection, pass third parameter, pctvol, new sorted collection. doing wrong? know problem lies in pctvol = group.selecct(item => item.pctvol) line.
var inbetween = this.groupby(item => item.housename) .select(group => new dataitem { housename = group.key, volume = group.sum(item => item.volume), pctvol = group.select(item => item.pctvol) }) .tolist(); observablecollection<dataitem> objsort = new observablecollection<dataitem>(inbetween.orderby(dataitem => dataitem.volume)); return objsort;
what kind of value want pctvol have? code, looks dataitem.pctvol ienumerable containing pctvol values in group.
if want single value, , pctvol values in each group guaranteed same, take value first element, this: pctvol = group.first().pctvol
Comments
Post a Comment