protected override Expression VisitJoin(JoinExpression join) { if (join.Join == JoinType.SingletonLeftOuter) { // first visit right side w/o looking at condition Expression right = this.Visit(join.Right); AliasedExpression ax = right as AliasedExpression; 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(JoinExpression join) { Expression result = base.VisitJoin(join); join = result as JoinExpression; if (join != null) { AliasedExpression right = join.Right as AliasedExpression; if (right != null) { AliasedExpression similarRight = (AliasedExpression)this.FindSimilarRight(join.Left as JoinExpression, join); if (similarRight != null) { this.map.Add(right.Alias, similarRight.Alias); return(join.Left); } } } return(result); }