IList<MyObject> ob1 = {new MyObject {Id = "1", Items = {BananaObject1, BananaObject2}}}
IList<MyObject> ob2 = { new MyObject {Id = "1", Items = {BananaObject2, BananaObject3}},
new MyObject {Id = "2", Items = {BananaObject3, BananaObject3}}}
I want to combine 2 lists so that the resulting list is
IList<MyObject> ob2 = { new MyObject {Id = "1", Items = {BananaObject1, BananaObject2, BananaObject3}},
new MyObject {Id = "2", Items = {BananaObject3, BananaObject3}}}
Since the identifier of the first element of the 2 lists was the same, they became a single entity, and one of their properties was combined.
I can do a for loop to achieve this, but I am looking for an optimal linq expression for this.
Thank you
source
share