[release/6.0] Query: Assign proper type to collection result expression (part 2) #27664
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.
This improves the fix made in #27134
In earlier PR we converted
IQueryable<T>
toIEnumerable<T>
becaused we converted enumerable to queryable during preprocessing phase and types aligned in later phase since we create a list (which does implementIEnumerable<T>
). Though this implementing behavior doesn't work when returning a single result of enumerable during async which wraps collection type inside Task.The better fix is to assign
List<T>
as type since we are eventually creating a list.In case of single result, the single result operator has generic type which will introduce convert node into it automatically which will match types for async tasks.
Resolves #27600
Description
Applying single result operator (First(OrDefault) and family) on queryable of enumerable throws exception during async code path due to mismatch type in the delegate.
Customer impact
Customers running query which are affected by scenario will see exception rather than correct results.
How found
Customer reported on 6.0.2
Regression
Yes, introduced on 6.0.2 through #27134
Testing
Added test for affected scenario.
Risk
Low. This change makes type closer to what we actually generate at runtime. Also added quirk to revert back to older behavior.