NH-3111: Linq incorrect replaces member access expressions with joins in subqueries. #93

Merged
merged 4 commits into from Apr 6, 2012

Projects

None yet

2 participants

Owner
hazzik commented Apr 6, 2012

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
         {
          ol.Discount,
          ShipperPhoneNumber = db.Shippers
            .Where(sh => sh.ShipperId == ol.Order.Shipper.ShipperId)
            .Select(sh => sh.PhoneNumber)
            .FirstOrDefault()
        })).ToList();

I've added check that joins is applied only for the correct query model.

JIRA: https://nhibernate.jira.com/browse/NH-3111

@oskarb oskarb merged commit f0b8919 into nhibernate:master Apr 6, 2012
Owner
oskarb commented Apr 6, 2012

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.

Owner
hazzik commented Apr 7, 2012

I wonder if we could just update ODP.NET to fix those issues.

Owner
oskarb commented Apr 9, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment