Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linq Fetch over component after fetching a many-to-one throws exception #2511

Closed
cremor opened this issue Sep 3, 2020 · 0 comments
Closed

Comments

@cremor
Copy link
Contributor

cremor commented Sep 3, 2020

I have a Linq query that looks like this:

session.Query<MyEntity>()
    .Fetch(x => x.UnrelatedManyToOneProperty)
    .Fetch(x => x.ComponentProperty).ThenFetch(x => x.ManyToOneInComponent)
    .Where(x => x.Id == someId)
    .ToArray();

This query worked in NHibernate 5.2.7 (although it didn't actually fetch the many-to-one in the component, see #1232). But with NHibernate 5.3.2 this query now throws an exception:

InvalidOperationException: Property x.ComponentProperty does not exist on entity TypeOfUnrelatedManyToOneProperty
   at NHibernate.Persister.Entity.AbstractEntityPersister.PropertySelectFragment(String name, String suffix, ICollection`1 fetchProperties, Boolean allProperties)

If I remove the .Fetch(x => x.UnrelatedManyToOneProperty) part of the query it works (and even correctly fetches the many-to-one in the component, which means that #1232 was fixed, except that we now have this regression).

@fredericDelaporte fredericDelaporte added this to the 5.3.3 milestone Sep 3, 2020
@fredericDelaporte fredericDelaporte changed the title [5.3.x regression] Linq Fetch over component after fetching a many-to-one throws exception Linq Fetch over component after fetching a many-to-one throws exception Sep 3, 2020
hazzik pushed a commit that referenced this issue Sep 8, 2020
Fixes #2511

Co-authored-by: Roman Artiukhin <bahusdrive@gmail.com>
@hazzik hazzik added the r: Fixed label Sep 8, 2020
@hazzik hazzik closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants