LINQ return items in a List that matches any Names (string) in another list

前端 未结 5 1282
故里飘歌
故里飘歌 2020-12-08 00:46

I have 2 lists. 1 is a collection of products. And the other is a collection of products in a shop.

I need to be able to return all shopProducts if the names match a

5条回答
  •  旧时难觅i
    2020-12-08 01:20

    Try this please

    var products  = shopProducts.Where(m=> listOfProducts.Select(l=>l.Name).ToList().Contains(m=>m.Name));
    

提交回复
热议问题