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); }
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 condition = new GroupCondition(); condition.Relation = relation; var leftVisitor = new WhereExpressionVisitor(this.Context); leftVisitor.Visit(node.Left); condition.Left = leftVisitor.Condition; var rightVisitor = new WhereExpressionVisitor(this.Context); rightVisitor.Visit(node.Right); condition.Right = rightVisitor.Condition; return(condition); }
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; }