3

I am trying to use linqkit to Predicate. Getting following code when I am trying 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 a definition for 'Where' and the best extension method overload '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.Expressions.Expression>

Please suggest me what I need to do fix it.

Thanks

user1211185
  • 731
  • 3
  • 12
  • 27

2 Answers2

3

I believe you are using Dynamics CRM. So following should work for you.

var query = from p in context.ProductSet
        .AsExpandable().Where(predicate) select p;
Scorpion
  • 4,495
  • 7
  • 39
  • 60
0

Did you try doing something like this?

var query = context.Products.AsExpandable().Where(predicate);
ivamax9
  • 2,601
  • 24
  • 33