【发布时间】:2019-01-09 12:28:49
【问题描述】:
我有List<List<ProductFilter>>
public class ProductFilter
{
public int Id { get; set; }
public int FilterValueId { get; set; }
public int ProductId { get; set; }
public int? FilterId { get; set; }
public string FilterValue { get; set; }
public string FilterName { get; set; }
}
我想要Intersect by ProductId 并返回 ProductFilter。有可能吗?
我试试看:
var intersection = groupList
.Aggregate((previousList, nextList) => previousList
.Select(x => x.ProductId)
.Intersect(nextList.Select(x => x.ProductId))
.ToList());
但它给了我错误,因为返回 int:
无法隐式转换类型“
System.Collections.Generic.List<int>” 到'System.Collections.Generic.List<ProductFilter>'
【问题讨论】:
标签: c# sql .net linq intersect