Exemplo n.º 1
0
        private Condition GetRelationCondition(string relation, BinaryExpression node)
        {
            var leftVisitor = new BinaryExpressionVisitor(this.Context);

            leftVisitor.Visit(node.Left);

            var rightVisitor = new BinaryExpressionVisitor(this.Context);

            rightVisitor.Visit(node.Right);

            if (leftVisitor.Column != null && rightVisitor.Column != null)
            {
                var condition = new SingleCondition();
                condition.Left     = leftVisitor.Column;
                condition.Right    = rightVisitor.Column;
                condition.Relation = relation;
                return(condition);
            }
            var group = new GroupCondition();

            group.Left = leftVisitor.Condition ?? new SingleCondition()
            {
                Right = leftVisitor.Column
            };
            group.Right = rightVisitor.Condition ?? new SingleCondition()
            {
                Right = rightVisitor.Column
            };
            group.Relation = relation;
            return(group);
        }
Exemplo n.º 2
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            var visitor = new BinaryExpressionVisitor(context);

            visitor.Visit(node);

            return(node);
        }
Exemplo n.º 3
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            switch (node.NodeType)
            {
            case ExpressionType.AndAlso:
                this.Condition = GetRelationCondition(" and ", node);
                break;

            case ExpressionType.OrElse:
                this.Condition = GetRelationCondition(" or ", node);
                break;

            default:
                var visitor = new BinaryExpressionVisitor(this.Context);
                visitor.Visit(node);
                this.Condition = visitor.Condition;
                break;
            }
            return(node);
        }
Exemplo n.º 4
0
        private Condition GetRelationCondition(string relation, BinaryExpression node)
        {
            var leftVisitor = new BinaryExpressionVisitor(this.Context);
            leftVisitor.Visit(node.Left);

            var rightVisitor = new BinaryExpressionVisitor(this.Context);
            rightVisitor.Visit(node.Right);

            if (leftVisitor.Column != null && rightVisitor.Column != null)
            {
                var condition = new SingleCondition();
                condition.Left = leftVisitor.Column;
                condition.Right = rightVisitor.Column;
                condition.Relation = relation;
                return condition;
            }
            var group = new GroupCondition();
            group.Left = leftVisitor.Condition ?? new SingleCondition() { Right = leftVisitor.Column };
            group.Right = rightVisitor.Condition ?? new SingleCondition() { Right = rightVisitor.Column };
            group.Relation = relation;
            return group;
        }