-
Notifications
You must be signed in to change notification settings - Fork 168
support IAsyncenumerable #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support IAsyncenumerable #988
Conversation
e55bd00
to
facbbc1
Compare
aec82d6
to
8b70194
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't appear that we are processing the IAsyncEnumerable
asynchronously (i.e. using await foreach
). I think that's the whole point of this PR.
I think you should also test with |
163a3ef
to
2c9bc0f
Compare
32bfb13
to
cdc77e0
Compare
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Show resolved
Hide resolved
test/Microsoft.AspNetCore.OData.E2E.Tests/IAsyncEnumerableTests/IAsyncEnumerableController.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.AspNetCore.OData.E2E.Tests/IAsyncEnumerableTests/IAsyncEnumerableTests.cs
Show resolved
Hide resolved
test/Microsoft.AspNetCore.OData.E2E.Tests/IAsyncEnumerableTests/IAsyncEnumerableTests.cs
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
99a7a2e
to
e3c051b
Compare
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
fb49252
to
abbe5f8
Compare
src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSetSerializer.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/Microsoft.AspNetCore.OData.E2E.Tests/IAsyncEnumerableTests/IAsyncEnumerableDataModel.cs
Show resolved
Hide resolved
ed711a6
to
99139b7
Compare
99139b7
to
ad74c81
Compare
Doesn't appear to work in all cases? |
This PR fixes #390
Currently, If you have such a controller action method in OData AspNetCore:
The request is processed asynchronously and a non-OData response is returned.
This change ensures that an OData response is returned.
The issue was,
AspNetCore OData
could not map anIAsyncEnumerable<>
to anEdmCollectionType
. To theDefaultODataTypeMapper
I've added a check for anIAsyncEnumerable<>
. If the collection is of typeIAsyncEnumerable<>
then it is mapped to anEdmCollectionType
.If we map the
IAsyncEnumerable<>
to anEdmCollectionType
then theODataResourceSetSerializer
is used in serializing the response.To the
ODataResourceSetSerializer
I've added a check for the collection type. If the type is ofIAsyncEnumerable<>
then we use theawait foreach
to loop through the resources in the collection. Otherwise, we use the normalforeach
loop.