1

CustomerID と ProductCode を含む単純なテーブルがあります。次の Linq クエリを使用して、10EDUCまたは12CONV を購入し、10CONV および 11CONV を購入しなかったすべての ID のリストを取得します。私がする必要があるのは、10EDUC と 12CONV を購入し、10CONV11CONV を購入しなかった人の ID を返すようにすることです。

何かご意見は?ティア

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);
4

0 に答える 0