Adding an item to a Collection within a Collection
This is my object structure,
Group has
List of Offers
Offer has
GroupId
List of Products
How can I add a product to the already existing List of products based on Group ID
This code is adding the Product but overwriting the existing product
Group.OffersList.Where(x => x.GroupId == "1开发者_如何转开发")
.SelectMany(x => x.ProductList)
.ToList().Add(Product);
Group.OffersList.Where(x => x.GroupId == "1")
.ToList()
.ForEach(x => x.Add(Product));
精彩评论