반응형
Let's see how we can get data asynchronously using Entity Framework.
Setting Up a Project
Creating an Application
Adding Relationship
For better demonstration, I have created three entities
Adding Repository Pattern
Adding Generic Repository Pattern
Setting Up Asynchronous
Asynchronous uses a type called Task
Updating the Controller with Asynchronous Methods
Open the controller class and add Task type with async and await to the methods
Updating the Interface with Asynchronous Methods
Move to the repository interface and update methods with Task
Updating the Repository with Asynchronous Methods
In the implementation class, update implemented methods to Task type with async and await to the methods
Run
Move to the API folder
cd /API
And run the app
dotnet watch
You will see added endpoints right away like below if you are using Swagger
Open each and try
We have seen how we can get data asynchronously using the Entity Framework
728x90
반응형
'Backend > .NET' 카테고리의 다른 글
Using Static Files (0) | 2023.04.19 |
---|---|
Data Transfer Object (DTO) (0) | 2023.04.19 |
Relational DB - Getting Data including Data from Other Entities (Generic Repository Pattern) (0) | 2023.04.15 |
Relational DB - Getting Data including Data from Other Entities (Repository Pattern) (0) | 2023.04.12 |
Application Architecture - Generic Repository (0) | 2023.04.09 |