添加项目到集合集合
问题描述:
这是我的对象结构中,添加项目到集合集合
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);
答
Group.OffersList.Where(x => x.GroupId == "1")
.ToList()
.ForEach(x => x.Add(Product));