I have a lambda expression like
x => x.Property0 == "Z" && old.Any(y => y.Key0 == x.Key0 && y.Property0 != x.Property0)
This expression is passed into the method as a string because it comes from a configuration file. That means I have to convert the string into an expression in order to then execute it.
public override async Task<IList<T>> CalculateList<T>(IList<T> old, IList<T> current)
{
string filter = "x => x.Property0 == \"Z\" && old.Any(y => y.Key0 == x.Key0 && y.Property0 != x.Property0)";
var exp = DynamicExpressionParser.ParseLambda<T, bool>(ParsingConfig.Default, false, filter, new object[0]);
var func = exp.Compile();
return current.Where(func).ToList();
}
If I only enter "x => x.Property0 == \" Z \""
in the filter variable, then the result fits, so the problem seems to be the old.Any, but I have not yet found a solution to the problem . However, no error is thrown, so no indication of the problem.
Can anyone tell me why the expression is not working correctly, or what I need to adjust to make it work.
Thanks