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

Activity

Show:
Alex Zaytsev
June 4, 2012, 8:12 PM

Sorry, probably it was fixed in 3.3.0, please check. Also there is issue related to this

Alex Zaytsev
June 4, 2012, 8:03 PM

Fix commited to master 6195424ffa3f1cb884a6983e847e26dcb45f4859

Juanita Vollmering
January 26, 2012, 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, 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, 4:05 PM

That's very interesting. Thanks for the tip!

Fixed

Assignee

Alex Zaytsev

Reporter

Daniel Guenter

Labels

Components

Fix versions

Affects versions

Priority

Major