[6.0] Query: Throw for FromSql+Any pattern which has been mutated #26211
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.
Part of #26167
Description
An exception is thrown for a certain pattern of raw SQL query that then uses
.Any
in LINQ. Fixing this for 6.0 is considered too risky, but we can detect when we're going to throw the exception, so we are making that exception more helpful. The workaround is to use.Count
instead, which is pretty easy once it is known.Customer impact
This is a relatively simple query, so we expect more customers to hit this. Helping them find the workaround will be useful.
How found
Customer reported.
Regression
Yes, in 6.0.
Testing
Tests added to make sure that the new exception is thrown.
Risk
Low. The fix just changes the exception thrown.