Skip to content

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

@cremor

Description

@cremor

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions