public static string ExpressionToString(this BinaryExpression body, IExpressionFunctions expressionFunctions)
        {
            Expression left       = body.Left;
            Expression right      = body.Right;
            string     nodeString = expressionFunctions.GetOperatorNode(body.NodeType);

            string leftString = (left is BinaryExpression leftB) ?
                                $"{leftB.ExpressionToString(expressionFunctions)}{nodeString} " :
                                $"{(left as MemberExpression).Member.Name}{nodeString}";

            return((right is BinaryExpression rightB) ?
                   $"{leftString}{rightB.ExpressionToString(expressionFunctions).NormalizeString()}" :
                   $"{leftString}{right.ToString().NormalizeString()} ");
        }
Exemple #2
0
        public static string GenerateWhere <TEntity>(Expression <Func <TEntity, bool> > identifierExpression, IExpressionFunctions expressionFunctions)
        {
            // TODO: verificar se é um binary, se for um member concatenar com == true
            BinaryExpression body = identifierExpression.Body as BinaryExpression;

            return($" WHERE {body.ExpressionToString(expressionFunctions).SubstringLast(1)}");
        }