我有3个具有以下属性的类:
OfferList类:
Guid Id
IEnumerable<Offer> Offers
提供课程:
Guid Id
Product Product
产品类别:
Guid Id
OfferList包含多个商品,商品包含1个商品。
如何获得包含OfferList的所有产品的IEnumerable?
OfferList offerList = this.GetOfferList(id);
IEnumerable<Product> products = offerList.Offers.SelectMany?
答案 0 :(得分:7)
您只需要project:
IEnumerable<Product> products = offerList.Offers.Select(o => o.Product);