c# - Linq aggregate with strings only returns one item instead of two -
although have 2 items in w.refrigeratordetails collection, aggregated string shows data second item, not first.
why that?
refrigeratordetails = w.refrigeratordetails .select((value, index) => new { value = value, index = index + 1 }) .aggregate(string.empty, (current, item) => "test1" + item.index + ": " + item.value.serialnumber + environment.newline + "test2" + item.index + ": " + item.value.articlenumber + environment.newline + "test3" + item.index + ": " + (item.value.dateofpurchase.hasvalue ? item.value.dateofpurchase.value.toshortdatestring() : "") + environment.newline + environment.newline)
because when you're aggregating data you're ignoring current
, , projecting each additional record item containing records data without incorporating previous data.
Comments
Post a Comment