runxc1 / MicroRuleEngine

A .Net Rule Engine for dynamically evaluating business rules compiled on the fly.
MIT License
185 stars 74 forks source link

BuildExpr fails to pass useTryCatch to BuildNestedExpression #26

Open RubberChickenParadise opened 4 years ago

RubberChickenParadise commented 4 years ago

in MRE.cs approx line 346, BuildExpr fails to pass useTryCatch causing complex nested rules to use the incorrect (when useTryCatch = false) values.

if (enumrOperation != null)
            {
                var elementType = ElementType(propType);
                var lambdaParam = Expression.Parameter(elementType, "lambdaParam");
                return rule.Rules?.Any() == true
                    ? Expression.Call(enumrOperation.MakeGenericMethod(elementType),
                        propExpression,
                        Expression.Lambda(
                            BuildNestedExpression(elementType, rule.Rules, lambdaParam, ExpressionType.AndAlso),
                            lambdaParam)

                    )
                    : Expression.Call(enumrOperation.MakeGenericMethod(elementType), propExpression);
            }