You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello @Toxic-Cookie.
There is nothing in ExpressionEvaluator to return a compiled predicate or a other delegate.
As everything is evaluate on the fly and do not compile.
If you are not concern about performance you could encapsulate it like this :
stringpredicateText="x.Equals(1)";Predicate<int>predicate= x =>(bool)(newExpressionEvaluator(new{x=x}).Evaluate(predicateText));Console.WriteLine(predicate(1));// trueConsole.WriteLine(predicate(5));// false
Otherwise there are others libraries like DynamicExpresso that support this use case with better performances :
My goal is to convert a string into a predicate like so:
Is this possible? If so how can I accomplish this?
The text was updated successfully, but these errors were encountered: