Trying to use ParseLmabda method available in System.Linq.Dynamic.Core library. When I execute the following simple example.
using (var context = new EntityContext())
{
Expression<Func<Customer, bool>> e1 = System.Linq.Dynamic.Core.DynamicExpressionParser
.ParseLambda<Customer, bool>(null, true, "City = @0", "London");
var customers = context.Customers.Where("@0(it)", e1).ToList();
}
it throws the following exception.
System.NotSupportedException: 'The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.'
Any idea what I am doing wrong?
Did you try this code:
Expression<Func<Customer, bool>> e1 = DynamicExpressionParser.ParseLambda<Customer, bool>(null, true, "City = @0", "London");
var customers = Customers.Where(e1).ToList();
Actually, code below should just work fine.
var e1 = DynamicExpressionParser.ParseLambda<Customer, bool>(new ParsingConfig(), true, "City = @0", "London");
var e2 = DynamicExpressionParser.ParseLambda<Customer, bool>(new ParsingConfig(), true, "c => c.CompanyName != \"test\"");
var customers = context.Customers.ToList().AsQueryable().Where("@0(it) and @1(it)", e1, e2);
See example: https://dotnetfiddle.net/PF9Htk