Beispiel #1
0
        public void Parse(Expression left, Expression right, Expression result)
        {
            step = 1;
            Visit(left);
            step = 2;
            Visit(right);


            Condition lastCondition = new SingleCondition()
            {
                Left = leftColumns.First(), Relation = " = ", Right = rightColumns.First()
            };

            for (int i = 1, len = leftColumns.Count; i < len; i++)
            {
                var groupCondition = new GroupCondition()
                {
                    Left = lastCondition, Relation = " and "
                };
                var condition = new SingleCondition();
                condition.Left       = leftColumns[i];
                condition.Relation   = " = ";
                condition.Right      = rightColumns[i];
                groupCondition.Right = condition;
                lastCondition        = groupCondition;
            }
            this.Condition = lastCondition;
            step           = 3;
            Visit(result);
        }
Beispiel #2
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);
        }
        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;
        }