[release/8.0] Add method postfix when rewriting parameters for StartsWith/EndsWith/Contains #32440
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 #32432, backports #32433.
Description
EF 8.0 optimizes the translations of string.StartsWith/EndsWith/Contains for when the pattern is a parameter:
Unfortunately, if the same pattern parameter is used for two different methods in the same query (i.e. Contains and StartsWith), only one parameter is sent to the database, with whatever pattern comes last (i.e.
%foo%
for Contains,foo%
for StartsWith).Customer impact
When using the same pattern parameter for two different methods in the same query, the query is translated incorrectly and the user may receive incorrect results (data corruption bug).
How found
Customer reported on 8.0
Regression
Yes
Testing
Added.
Risk
Very low; quirk added.