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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -