Skip to content

Optimize translation of comparison of two nullables without both being null #32464

@roji

Description

@roji

Currently, if a user wants to filter where two nullables are equal except when both are null, they need to write .Where(b => b.X == b.Y && b.X != null && b.Y != null); this generates lots of needless SQL (the situation is between if the null checks are to the left of the equality, but still not ideal).

Because of relational null semantics, it's enough to just do x = y; we could detect the LINQ null checks and optimize the translation.

Note: think about negated context when designing for this.

Scenario raised by @GertArnold in #32453

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions