nhibernate/nhibernate-core — pull request #70 by hazzik (2012-01-30 18:32:48+00:00)
Title: NH-2904: Linq - wrong query generation with LINQ subquery with contains 

Query

```csharp
var subquery = from line in db.OrderLines
select line.Order;

var query = (from order in db.Orders
where subquery.Contains(order)
select order).ToList();
```

Generates wrong SQL:

```sql
select
order0_.*
from
Orders order0_
where
exists (
select
order2_.OrderId
from
OrderLines orderline1_
left outer join
Orders order2_
on orderline1_.OrderId=order2_.OrderId
where
orderline1_.OrderLineId=order0_.OrderId -- this part is incorrect.
)
```