-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query :: Include with multiple navigations (including optional navigation) fails #5672
Comments
@maumar does this look familiar? In triage we discussed that the NRE may come from |
@ImmePak can you provide some more information? im unable to reproduce this. Ideally provide standalone repro. Otherwise please provide code for Org class and a complete code for OnModelCreating. If you are using sample data, that would be great also. |
@ImmePak as a workaround you can try using two queries, first one would gather all the Ids needed, and the other one would perform the query: var memberIds = _provider.Members.Where(m => m.State.Org.Id == idfOrg).Select(m => m.Id).ToList();
var query = _provider.Members.Include(m => m.State).ThenInclude(s => s.Org)
.Where(m => memberIds.Contains(m.Id)).ToList() |
@maumar as you asked: EF OnModelCreating code
Expanded class code
|
I was able to reproduce the issue. It is a legitimate bug, looking into it... |
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element.
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element.
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element.
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element.
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element. CR: Andrew
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element. CR: Andrew
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element. CR: Andrew
…optional navigation) fails Problem was that our include logic for groupjoin was expecting outer and inner elements (on which the include was being performed) to be entities. However sometimes those elements would be TransparentIdentifiers (e.g. when the element comes from a result of SelectMany). Fix is to also store (when necessary) the accessor from the outer/inner element to the entity that we want to include, extract the actual entity in runtime and apply include operations on that entity instead of the actual outer/inner element. CR: Andrew
fixed in 5f48163 |
I`am running ASP.NET Core 1.0 application, using EF7 rc2
Part of class structure:
So, first goal was to make field Org in MemberState nullable and I configured EF context in the following way:
It was fine before i have need to search Members by Org.Id
First approach, that worked before i marked Org field as nullable:
Now it start firing exception : Object reference not set to an instance of an object.
Considering the fact that database not contains any record of MemberState with NULL in Idf_Org it was quite strange.
but this one is working O_o but give me unappropriate result (all included instances is null)
One way i found is to do direct SQL query in that way
The question is follows:
The text was updated successfully, but these errors were encountered: