Linq ThenFetch fails on deep where clause.

Description

Using a deep recursion in a where statement

.Where(p => p.Address.City.Name == "Test")

will cause a ThenFetch statement to fail with the following exception.

"Query specified join fetching, but the owner of the fetched association was not present in the select list "

var query = session.Query<Person>()
.Where(p => p.Address.City.Name == "Test")
.Fetch(r => r.Address)
.ThenFetch(a => a.City);

Removing the where statement or shortening it will cause the query to pass.

Environment

None

Attachments

1
  • 22 Aug 2011, 11:01 PM

Activity

Show:

Alex Zaytsev June 4, 2012 at 8:12 PM

Sorry, probably it was fixed in 3.3.0, please check. Also there is https://nhibernate.jira.com/browse/NH-3115#icft=NH-3115 issue related to this

Alex Zaytsev June 4, 2012 at 8:03 PM

Fix commited to master 6195424ffa3f1cb884a6983e847e26dcb45f4859

Juanita Vollmering January 26, 2012 at 8:39 AM

The same issue seems to apply when using OrderBy in conjunction with Fetch()/ThenFetch().

Unfortunately, I have no control in my code in which order these methods are called on the Queryable. This turns out to be a major issue for me.

Mike Schuld January 12, 2012 at 11:43 PM

Swapping the Fetch to the top does not always work. I have some very long Where clauses that are still getting this same problem even with the Fetch.ThenFetch being above everything else.

Daniel Guenter December 8, 2011 at 4:05 PM

That's very interesting. Thanks for the tip!

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?

Created August 22, 2011 at 11:01 PM
Updated September 21, 2014 at 12:40 PM
Resolved June 4, 2012 at 8:03 PM
Who's Looking?

Flag notifications