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

Query: SubQueryMemberPushdown doesn't work for chained navigation properties #8526

Closed
maumar opened this issue May 19, 2017 · 4 comments
Closed
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported punted-for-2.0 type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented May 19, 2017

SubQueryMemberPushdown optimization can only optimize one member per pass. We should consider making it work for more complex scenarios with multiple properties chained off one another.

example:

l3s.Select(l3 => l3s.OrderBy(l => l.Id).First().OneToOne_Required_FK_Inverse.OneToOne_Required_FK_Inverse.Name)

initial QM:

from Level3 l3 in DbSet<Level3>
select 
    (from Level3 l in DbSet<Level3>
    order by [l].Id asc
    select [l]).First().OneToOne_Required_FK_Inverse.OneToOne_Required_FK_Inverse.Name

after first pushdown:

from Level3 l3 in DbSet<Level3>
select 
    (from Level3 l in DbSet<Level3>
    order by [l].Id asc
    select [l].OneToOne_Required_FK_Inverse).First().OneToOne_Required_FK_Inverse.Name

after nav rewite:

from Level3 l3 in DbSet<Level3>
select 
    (from Level3 l in DbSet<Level3>
    join Level2 l.OneToOne_Required_FK_Inverse in DbSet<Level2>
    on Property([l], "Level2_Required_Id") equals Property([l.OneToOne_Required_FK_Inverse], "Id")
    order by [l].Id asc
    select [l.OneToOne_Required_FK_Inverse]).First().OneToOne_Required_FK_Inverse.Name

after second pushdown:

from Level3 l3 in DbSet<Level3>
select 
    (from Level3 l in DbSet<Level3>
    join Level2 l.OneToOne_Required_FK_Inverse in DbSet<Level2>
    on Property([l], "Level2_Required_Id") equals Property([l.OneToOne_Required_FK_Inverse], "Id")
    order by [l].Id asc
    select [l.OneToOne_Required_FK_Inverse].OneToOne_Required_FK_Inverse).First().Name

This query ends up throwning NRE - we should be able to fully translate it though, push all the members inside the selector and only then run nav rewrite

@maumar
Copy link
Contributor Author

maumar commented Jun 8, 2017

After fixing unskip test in ComplexNavigationsOwnedQueryTestBase for #8248

@maumar
Copy link
Contributor Author

maumar commented May 9, 2019

this has been done as part of nav expansion rework. the remaining work is to extract the logic to a separate visitor

@divega
Copy link
Contributor

divega commented Jun 20, 2019

@maumar to close this as fixed and create a new issue.

@maumar
Copy link
Contributor Author

maumar commented Jun 20, 2019

this is fixed in the current bits, filed #16180 to track the cleanup work

@maumar maumar closed this as completed Jun 20, 2019
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 20, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0, 3.0.0-preview7 Jul 2, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0-preview7, 3.0.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported punted-for-2.0 type-bug
Projects
None yet
Development

No branches or pull requests

4 participants