Asynchronous operation Repository
See original GitHub issueABP 1.4.1
var query = _userTypeRepository.GetAll();
var total = query.CountAsync();
var rows = query.Skip(input.Rows * (input.Page - 1)).Take(input.Rows).ToListAsync();
return new GetXXXOutput { Total = await total, Rows = await rows };
The above code will randomly appear the following error:
"Unexpected connection state. When using a wrapping provider ensure that the StateChange event is implemented on the wrapped DbConnection."
"A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe."
"An error occurred while executing the command definition. See the inner exception for details."
It seems that EF DBContext is not thread safe, if we want to abp in the data on the operation, there is any good way?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Asynchronous Generic Repository in ASP.NET Core Web API
Async programming is a parallel programming technique, which allows the working process to run separately from the main application thread. As ...
Read more >domain driven design - Are repositories async?
@Ced, it is entirely possible to provide a synchronous interface to an inherently async operation. It just means that whatever waiting needs to ......
Read more >Async Programming in C# Repository Pattern
To create an asynchronous API, you need to make all the methods from start to end asynchronous. Asynchronous is actually beneficial for I/O ......
Read more >Implementing an async Repository and Unit of Work with ...
This article explains how to implement the Repository and Unit of Work patterns in .NET Core applications, exposing an asynchronous interface ...
Read more >Asynchronous Programming - EF Core
Async operations are important for keeping a responsive UI in rich client applications, and can also increase throughput in web applications ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
BTW, Async pattern’s advantage is not multi-threading. It’s a different topic.
You missed “await” keywords for CountAsync and ToListAsync