这是我的对象结构,
Group has
List of Offers
Offer has
GroupId
List of Products
如何根据组ID
将产品添加到现有产品列表中此代码正在添加产品,但会覆盖现有产品
Group.OffersList.Where(x => x.GroupId == "1")
.SelectMany(x => x.ProductList)
.ToList().Add(Product);
答案 0 :(得分:0)
Group.OffersList.Where(x => x.GroupId == "1")
.ToList()
.ForEach(x => x.Add(Product));