Example #1
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            var sign = string.Empty;

            switch (node.NodeType)
            {
            case ExpressionType.Equal:
                sign = "=";
                break;

            case ExpressionType.NotEqual:
                sign = "!=";
                break;

            case ExpressionType.GreaterThan:
                sign = ">";
                break;

            case ExpressionType.LessThan:
                sign = "<";
                break;

            case ExpressionType.AndAlso:
                sign = "AND";
                break;

            case ExpressionType.OrElse:
                sign = "OR";
                break;
            }


            if (node.Left.NodeType == ExpressionType.Parameter)
            {
                sqlQueryBuilder.AddCurrentProperty();
            }
            else
            {
                Visit(sqlQueryBuilder, node.Left);
            }

            sqlQueryBuilder.AddBinaryOperation(sign);
            Visit(sqlQueryBuilder, node.Right);

            return(node);
        }