nreco / lambdaparser

Runtime parser for string expressions (formulas, method calls). Builds dynamic LINQ expression tree and compiles it to lambda delegate.
http://www.nrecosite.com/
MIT License
307 stars 55 forks source link

Exception when checking for null and other bool condition #12

Closed Shekesh closed 6 years ago

Shekesh commented 6 years ago

Hello,

when I try the following code

var value = "testString";
var env = new Dictionary<string, object>();
env.Add("value", value);
var parser = new LambdaParser();
string res = (string)parser.Eval("value != null && value.Contains(\"t\") ? \"contains\" : \"does not contain\"", env);

I get this exception: System.InvalidOperationException: "The binary operator AndAlso is not defined for the types 'System.Boolean' and 'NReco.Linq.LambdaParameterWrapper'."

There seems to be a problem combining a check for null with another condition. If I do only the null check there is no problem.

VitaliyMF commented 6 years ago

Fixed in 1.0.7