NH when transforms following kinds of queries places join for ol.Order into the subquery instead of outer query.
var list = (db.OrderLines
.Select(ol => new
ShipperPhoneNumber = db.Shippers
.Where(sh => sh.ShipperId == ol.Order.Shipper.ShipperId)
.Select(sh => sh.PhoneNumber)
I've added check that joins is applied only for the correct query model.
Add failing test for NH-3111
Fix for NH-3111 - SelectJoinDetector should try to rewrite sub queries
Add another test to check that we add joins only for correct query mo…
Add joins only for own query model.
Annoyingly, the tests fail on Oracle due to the version used in the auto-build not being able to handle references to identifiers more than one nesting level up. Not sure what to do about this.
I wonder if we could just update ODP.NET to fix those issues.
There seem to be rumours that when the subquery is in the select clause it cannot access anything beyond it's parent even in later Oracle versions. Haven't found any official reference of this though.