Skip to content
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

Feature request: Allow sync query in [EnableQuery] attribute #2399

Open
anranruye opened this issue Jan 20, 2021 · 4 comments
Open

Feature request: Allow sync query in [EnableQuery] attribute #2399

anranruye opened this issue Jan 20, 2021 · 4 comments

Comments

@anranruye
Copy link

anranruye commented Jan 20, 2021

Inspired by dotnet/efcore#23900

Since ASP.NET Core 3, web api will perform async query if the object action result implement IAsyncQueryable
IAsyncEnumerable. However, async query sometimes may cause serious performence issue.

When we use [EnableQuery] attribute, we can not control the final action result. If we want to perform sync query, it should be performed inner [EnableQuery].

This is a feature request. I think it's better to add a new bool property named Async to EnableQueryAttribute. If the property value is false, [EnableQuery] will perform db query before return the action result to the mvc pipeline.

@xuzhg
Copy link
Member

xuzhg commented Jan 20, 2021

@anranruye Are you using 7.5.4? Can you try 7.5.5?

@anranruye
Copy link
Author

anranruye commented Jan 20, 2021

@xuzhg I don't understand what to do with 7.5.5.

I mean, for a typical web api, we can use extention method IQueryable.ToList() or IQueryable.ToListAsync() to perform sync/async query.

However, if we directly return IQueryable as the action result, the framework will decide to perform sync or async operation depend on the queryable provider implements IAsyncQueryable IAsyncEnumerable<T> or not. This is what we can not control.

For the same reason, we can not control whether to perform sync or async query when we use OData Web Api, unless we don't use [EnableQuery] or write another action filter.

@anranruye anranruye changed the title Allow sync query in [EnableQuery] attribute Feature request: Allow sync query in [EnableQuery] attribute Jan 21, 2021
@xuzhg
Copy link
Member

xuzhg commented Jan 26, 2021

@xuzhg I don't understand what to do with 7.5.5.

@anranruye I misunderstood your question. Originally I though it could be related to the concurrency enable query problem that was fixed in 7.5.5. For your scenario, it seems it's a feature request. Thanks.

@gathogojr
Copy link
Contributor

@anranruye We highly encourage pull request contributions so if you're in a position to, you're welcome to chip in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants