Optimize translation of comparison of two nullables without both being null
Open
area-perf
area-query
customer-reported
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
Assessment
This issue has not been assessed yet.