Description
Bug description
I am trying to use Load on a navigation property, with Query then some Includes to explicitly loaded some child entities and some of their children. For example, consider an Entity A with a navigation property to a collection of entity B objects. Each entity B object has a reference to an entity C object. I am trying to call the following:
Entry(A).Collection(a => a.B).Query().Include(b => b.C).Load();
After calling this I'd expect Entry(A).Collection(a =>a.B).IsLoaded and Entry(A.B.First()).IsLoaded to return true, but they both return false. However, if I then explicitly load the collection of entity B again. and look to see if their entity C record has been loaded, it has.
It appears the Load has worked in as much as the Included objects have been brought into the context, but the actual Collection we tried to explicitly load has not. Trying to reference it causes it to be queried again
See the attached project for a demonstration. It first demonstrates that a simple load works, then attempts the scenario described in the bug description. It shows that the entity B child collection does not get loaded by the call to Load, and then explicitly loads it without the call to .Query(). It then checked whether the Entity C related object of the Entity B objects have been loaded, which they have, showing the initial Load with .Query().Include() fetched the entity C objects
It seems that either no Entity B or Entity C would be loaded, indicating Collection.Query.Include.Load is not supported, or both the entity B and entity C should be loaded. Having one but not the other seems inconsistent?
Your code
See the attached project for a demonstration.
Stack traces
Verbose output
EF Core version
9.0.3
Database provider
No response
Target framework
No response
Operating system
No response
IDE
No response