protected override Expression VisitJoin(DbJoinExpression join) { if (join.Join == DbJoinType.SingletonLeftOuter) { // first visit right side w/o looking at condition Expression right = this.Visit(join.Right); DbAliasedExpression ax = right as DbAliasedExpression; if (ax != null && !this.allColumnsUsed.ContainsKey(ax.Alias)) { // if nothing references the alias on the right, then the join is redundant return(this.Visit(join.Left)); } // otherwise do it the right way Expression cond = this.Visit(join.Condition); Expression left = this.Visit(join.Left); right = this.Visit(join.Right); return(this.UpdateJoin(join, join.Join, left, right, cond)); } else { // visit join in reverse order Expression condition = this.Visit(join.Condition); Expression right = this.VisitSource(join.Right); Expression left = this.VisitSource(join.Left); return(this.UpdateJoin(join, join.Join, left, right, condition)); } }
protected override Expression VisitJoin(DbJoinExpression join) { Expression result = base.VisitJoin(join); join = result as DbJoinExpression; if (join != null) { DbAliasedExpression right = join.Right as DbAliasedExpression; if (right != null) { DbAliasedExpression similarRight = (DbAliasedExpression)this.FindSimilarRight(join.Left as DbJoinExpression, join); if (similarRight != null) { this.map.Add(right.Alias, similarRight.Alias); return(join.Left); } } } return(result); }