我有一个简单的表,其中包含CustomerID&产品代码。使用以下Linq查询,我获得了购买10EDUC 或 12CONV并且未购买10CONV和11CONV的所有ID的列表。我需要做的是让它返回购买10EDUC 和 12CONV并且没有购买10CONV和11CONV的ID。
有什么想法? TIA
var IncludePredicate = PredicateBuilder.True<Products>();
var ExcludePredicate = PredicateBuilder.True<Products>();
List<string> IncludeProducts = new List<string>();
List<string> ExcludeProducts = new List<string>();
ExcludeProducts.Add("10CONV");
ExcludeProducts.Add("11CONV");
IncludeProducts.Add("10EDUC");
IncludeProducts.Add("12CONV");
IncludePredicate = IncludePredicate.And(m=>IncludeProducts.Contains(m.Service));
ExcludePredicate = ExcludePredicate.And(m => ExcludeProducts.Contains(m.Service));
var IncludeResults = (from d in Products
.AsExpandable()
.Where(IncludePredicate)
.Distinct()
select d.CustomerID
)
.Except(from ex in Services
.Where(ExcludePredicate)
select ex.CustomerID);