davidfowl/QueryInterceptor — pull request #1 by peschuster (2012-01-12 15:22:48+00:00)
Title: Wrong expression tree clean up, when there is more than one QueryTranslator

When a query contains more than one QueryTranslator, all QueryTranslator instances are replaced by the source expression of the base QueryTranslator.

## Example

var list = from country in this.Table()
join user in this.Table() on country equals user.CountryId
select user;

In this Example `Table()` returns an EntityFramework `ObjectSet` which is encapsulated by `QueryTranslator`. This was done to add ExpressionVisitors in a central place (in data layer) to all queries.

## The problem

The problem is that in `QueryTranslatorProvider.VisitConstant(..)` all instances of `QueryTranslator` are replaced by the source expression of the **current** `QueryTranslatorProvider`: https://github.com/davidfowl/QueryInterceptor/blob/master/QueryInterceptor/QueryTranslatorProvider.cs#L79

## The Solution

Pull `IQueryable _source` to a non-generic base class of `QueryTranslatorProvider` and return the source expression of the `QueryTranslator` which is currently visited.