-
Notifications
You must be signed in to change notification settings - Fork 161
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
Asynchronous calls to database with EnableQuery attribute [workaround solution] #1326
Comments
Duplicate of: |
@Forevka Are you able to achieve the async calls using: [HttpGet]
[EnableQuery]
public IAsyncEnumerable<Customer> Get()
{
return this.context.Customers.AsAsyncEnumerable();
} as suggested here OData/WebApi#2598 |
EDIT: As correctly pointed out by @rpallares, the above is actually not correct in this case. Because I was coming from a position of direct usages, where one would do Thank you for the correction @rpallares . |
In fact not. Because thé iasyncenumerable object returned by entityframework IS also an iqueryable. And enablequeryattribue IS smart enough to use both interfaces. With two limitations, the count exposed here and also pagination that load the quey result instead of stream it. |
Note exactly a duplicate. This one talk about the include count whereas the issue you linked talk about executing the query synchonously when pagination is activated. |
You are of course absolutely correct @rpallares . I've amended my previous post to highlight this. Thanks for the correction and sorry for the confusion @WanjohiSammy and @Forevka . |
Assemblies affected
ASP.NET Core OData 8.x and ASP.NET Core OData 9.x
Describe the bug
All database calls that are made in order to fetch data from IQueryable<> that returned from controller route are made synchronous
Reproduce steps
Data Model
Sample model (but it's don't really matter)
Expected behavior
I don't really know on which side the problem is, but: I expect that if my database connector and linq provider implements Async versions, EnableQuery attribute will use this overloads.
Screenshots
How it's now:
As you see on screenshot, database calls made synchronous
Additional context
Workaround was created in case anybody need it, but I hope it will be fixed inside library
How to use:
result:
all calls are made async
The text was updated successfully, but these errors were encountered: