-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
None
-
Dotnet Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Many providers allow direct entity comparisons, specifically these are:
.Where(e => e != null)
At the top level this is effectively .Where(true)
.Where(e => e == null)
At the top-level this effectively is .Where(false)
.Where(e => e == f)
At the top-level this is effectively key comparisons. e.g. Where(e => e.Id == f.Id)
.Where(e => e != f)
At the top-level this is effectively key comparisons. e.g. Where(e => e.Id != f.Id)
Solution
We should probably just match any direct comparisons to the key which will handle all these scenarios as well as odd ones like .Where(e => e > f) if EF doesn't prevent that.
Open questions
- Do we want to support owned entity comparisons? They don't have real keys so we'd have to do full-property comparisons which would be different from the top-level comparisons here and may match multiple entities as there is no ref integrity.