Entity equality: Contains and OrderBy #16134
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #15939
For Contains, I realized half-way through that the test (Contains_over_entityType_should_rewrite_to_identity_equality) depends on #15855, since the second query sends the ID selected in the first query. Am still submitting the implementation - the expression tree generated internally looks good. I can also hold off until #15855 is done.
Also, I tested the case
Orders.Contains(null)
and was surprised to see the null is parameterized. Is this intended?Finally, unrelated to EE: I understand the need to split into two queries for Single, since the 1-element verification needs to happen client-side. However, for First, FOD, Last, LOD we can translate as a single query:
(this is PostgreSQL, SQLServer requires the surrounding CASE for boolean). Is this optimization already tracked somewhere, should I open an issue?
For OrderBy, note that I've implemented support for composite keys, where we split the comparison into multiple OrderBy().ThenBy() operators.