mparlak / Flee

Fast Lightweight Expression Evaluator
624 stars 119 forks source link

Unable to cast object of type 'Flee.ExpressionElements.CompareElement' to type 'Flee.ExpressionElements.LogicalBitwise.AndOrElement' #15

Closed RLaptev closed 6 years ago

RLaptev commented 6 years ago

I'm getting Unable to cast object of type 'Flee.ExpressionElements.CompareElement' to type 'Flee.ExpressionElements.LogicalBitwise.AndOrElement' error when executing the following simple code:

ExpressionContext context = new ExpressionContext();
VariableCollection variables = context.Variables;
variables["a"] = "foo";
variables["b"] = "bar";
string s = "a = \"foo\" AND (b = \"bar\" OR b = \"foo\")";
IGenericExpression<bool> exp = context.CompileGeneric<bool>(s);

But if I change the order of logical operators to the one below (move AND check to the end), it works! string s = "(b = \"bar\" OR b = \"foo\") AND a = \"foo\"";

Thanks.

RLaptev commented 6 years ago

never mind, I upgraded to version 1.0.5 from 1.0.4 and the problem is now gone. Great project!

vesko-k commented 6 years ago

Please, review your NuGet package 1.0.5, assembly for net45 probably is older version, because the issue still exists. For net461 it's ok. Really awesome project! My query executed with Flee is 6 times faster than executed with Linq.Dynamic.