[release/10.0] Fix empty scalar collection support #37248
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.
Fixes #37216
Description
EF 10 made important improvements around the translation of parameterized collections (docs): when a parameter collection is used, rather than sending it as a JSON array (which resulted in performance issues), we now inline it as a set of parameters into the SQL. Unfortunately, the SQL construct for this (
VALUES) does not support empty sets, leading to a query failure when the parameterized collection is empty.Customer impact
Queries making use of parameterized collections with any LINQ operator (other than Contains) fail when that collection happens to be empty:
How found
Multiple customers reported on 10.0.0
Regression
Yes
Testing
Added
Risk
Very low, very small, targeted fix for the precise problematic case. Quirk added just in case.