コード例 #1
0
        public override DbExpression Visit(DbJoinExpression expression)
        {
            EntityUtil.CheckArgumentNull(expression, "expression");

            DbExpression result = expression;

            DbExpressionBinding newLeft  = this.VisitExpressionBinding(expression.Left);
            DbExpressionBinding newRight = this.VisitExpressionBinding(expression.Right);

            this.EnterScope(newLeft.Variable, newRight.Variable);
            DbExpression newCondition = this.VisitExpression(expression.JoinCondition);

            this.ExitScope();

            if (!object.ReferenceEquals(expression.Left, newLeft) ||
                !object.ReferenceEquals(expression.Right, newRight) ||
                !object.ReferenceEquals(expression.JoinCondition, newCondition))
            {
                if (DbExpressionKind.InnerJoin == expression.ExpressionKind)
                {
                    result = CqtBuilder.InnerJoin(newLeft, newRight, newCondition);
                }
                else if (DbExpressionKind.LeftOuterJoin == expression.ExpressionKind)
                {
                    result = CqtBuilder.LeftOuterJoin(newLeft, newRight, newCondition);
                }
                else
                {
                    Debug.Assert(expression.ExpressionKind == DbExpressionKind.FullOuterJoin, "DbJoinExpression had ExpressionKind other than InnerJoin, LeftOuterJoin or FullOuterJoin?");
                    result = CqtBuilder.FullOuterJoin(newLeft, newRight, newCondition);
                }
            }
            NotifyIfChanged(expression, result);
            return(result);
        }