2
List<Product> Prs = data.Products
                    .Where(x=> x.ProductColors
                                .Where(y=> y.Color=="blue")
                                .Select(z=> z.ProductID)
                                .Contains(x.ID) && x.ProductColors
                                                     .Where(y=> y.Color== "red")
                                                     .Select(z=> z.ProductID)
                                                     .Contains(x.ID))
                    .ToList(); 

如何 PredicateBuilder 多标准?

4

1 回答 1

3

类似于以下内容:

var inner = PredicateBuilder.False<Product>();
inner = inner.Or (p => p.Description.Contains ("foo"));
inner = inner.Or (p => p.Description.Contains ("far"));

var outer = PredicateBuilder.True<Product>();
outer = outer.And (p => p.Price > 100);
outer = outer.And (p => p.Price < 1000);
outer = outer.And (inner);

var results = data.Products.AsExpandable().Where(outer)

您可以在此处阅读有关 PredicateBuilder的更多信息

于 2012-06-06T10:57:25.187 回答