private static string Clean(Expression condition) { var binary = condition as BinaryExpression; string str = null; if (binary?.NodeType == ExpressionType.Equal) { var constant = binary.Right as ConstantExpression; if (constant != null && constant.Type == typeof(bool) && constant.Value.Equals(true)) { str = ExtensionReducer.Reduce(binary.Left).ToString(); } } if (str == null) { str = ExtensionReducer.Reduce(condition).ToString(); } if (str.StartsWith("(") && str.EndsWith(")")) { return(str.Substring(1, str.Length - 2)); } return(str); }
protected Expression Reduce(Expression source, Expression arg1) { if (arg1 == null) { return(Call(null, Method.Method, source)); } return(Call(null, Method.Method, source, ExtensionReducer.Reduce(arg1))); }
public static Exception MergeMultiParameterLambda(LinqExpression node, LinqExpression innerExpr) { return(new NotSupportedException($"Cannot merge method '{node.Method.Method.Name}' in expression '{ExtensionReducer.Reduce(node)}': one or more lambda expressions reference multiple lambda parameters. {localSplit}")); }