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: When doing optional nav expansion, we can sometimes avoid nullability safeguards, if the user has performed them already #6203

Closed
maumar opened this issue Jul 28, 2016 · 2 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 28, 2016

In query like this:

_db.EntityA.Where(c => c.EntityC != null && c.EntityC.IsActive);

we apply nullability safeguards on IsActive column because EntityC is optional navigation, like so:

_db.EntityA.Where(c => c.EntityC != null && (bool)(c.EntityC != null ? (bool?)c.EntityC.IsActive : null ));

We don't need them in this case, because query already constrained the results rows where EntityC is not null. We could detect this pattern and avoid some unnecessary complications. It doesn't matter much for relational, since the safeguards are optimized out anyway, but this could be of some value for InMemory store.

See #6195 for the full repro of the scenario

@smitpatel
Copy link
Contributor

Similar #4267

@rowanmiller rowanmiller changed the title Query :: when doing optional nav expansion, we can sometimes avoid nullability safeguards, if the user has performed them already Query: When doing optional nav expansion, we can sometimes avoid nullability safeguards, if the user has performed them already Jul 29, 2016
@rowanmiller rowanmiller added this to the Backlog milestone Jul 29, 2016
@smitpatel
Copy link
Contributor

Generated SQL

      SELECT [b].[Id]
      FROM [Blogs] AS [b]
      LEFT JOIN [Address] AS [a] ON [b].[Id] = [a].[BlogId]
      WHERE [a].[Id] IS NOT NULL AND ([a].[IsActive] = CAST(1 AS bit))

@smitpatel smitpatel modified the milestones: Backlog, 3.0.0 Nov 13, 2019
@smitpatel smitpatel added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed area-perf labels Nov 13, 2019
@smitpatel smitpatel self-assigned this Nov 13, 2019
smitpatel added a commit that referenced this issue Nov 13, 2019
smitpatel added a commit that referenced this issue Nov 21, 2019
smitpatel added a commit that referenced this issue Nov 22, 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. type-enhancement
Projects
None yet
Development

No branches or pull requests

4 participants