linq distinct

List<Product> distinctProduct = allProduct
  .GroupBy(p => new {p.Id, p.Name} )
  .Select(g => g.First())
  .ToList();

分组取第一条数据

posted @ 2019-11-28 13:05  刘中俊  阅读(234)  评论(0)    收藏  举报