[release/8.0] Fix parameter names for nested types in complex type equality (#33527) #33548
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 #33449
Backport of #33527
Description
When translating the equality comparison of two complex types, EF generates SQL to compare every property of the complex type to each other; when one of these complex type is a client-side parameter, EF constructs a new, synthetic parameter for each such property - recursively. However, the synthetic parameter names contained the name of the parameter and the name of the final (non-complex property), but did not contain the names of intermediate nested complex types containing the property. As a result, if a complex type contains two properties with the same name within different nested complex types, the same parameter name is generated and the old parameter is overridden.
Customer impact
When doing complex type comparison against a parameter, where multiple nested properties have the same name, an incorrect query is generated, leading either to an error or two data corruption (incorrect results being returned).
How found
Customer reported on 8.
Regression
No, complex type support is a new feature in EF8.
Testing
Test added.
Risk
Very Low. The fix is very localized and straightforward - we simply add nested property names when constructing the parameter name. A quirk was added just in case.