How to use predicates with LINQ for a CRM 2011 query
I am trying to use linqkit for Predicate. Getting the following code when I try to compile.
public void TestPredicate(Guid[] productIds)
{
var predicate = PredicateBuilder.False<Product>();
foreach (var productId in productIds)
{
var tempGuid = productId;
predicate = predicate.Or(p => p.ProductId== tempGuid);
}
}
var query = from p in context.CreateQuery("product")
.AsExpandable().Where(predicate) select p;
}
Error 1: "System.Linq.IQueryable" does not contain "Where" definition and no better overloading method. 'System.Linq.Queryable.Where (System.Linq.IQueryable, System.Linq.Expressions.Expression>)' has some invalid arguments
Error 2 Argument 2: Cannot convert from 'System.Linq.Expressions.Expression>' to 'System.Linq.Expressionions.Expression>
Please suggest me what I need to fix this.
thank
+3
source to share
2 answers