我需要动态地创建表达式。我的问题是如何在System.Linq.Expression中添加括号以处理优先级...
int a = 1, b = 1, c = 1, d = 2;
我已将以下表达式转换为:
var v = a > 1 || b > 1 && c > 1 || d > 1;
Expression case1Expr =
Expression.AndAlso(
Expression.OrElse(
Expression.GreaterThan(Expression.Parameter(typeof(int), "a"), Expression.Constant(1)),
Expression.GreaterThan(Expression.Parameter(typeof(int), "b"), Expression.Constant(1))),
Expression.OrElse(
Expression.GreaterThan(Expression.Parameter(typeof(int), "c"), Expression.Constant(1)),
Expression.GreaterThan(Expression.Parameter(typeof(int), "d"), Expression.Constant(1))));
但是如何转换带括号的表达式?
var v2 = (a > 1 || b > 1) && (c > 1 || d > 1);