In this post we are going to see the example 2 of implementation of repository pattern and unit of work in .Net10. we separate the project in to four layers.
1. Domain or Entities
2. Application or UseCase
3. Infrastructure
4. Controllers
Dependencies:
Solution Structure
Domain or Entities:
- It is consists of Entities.
- It is consists of Repositories and Unit Of Work Interfaces.
Application or UseCase
- It is consists of declaration of Application Service Interfaces with public access.
- It is consists of Implementation of Application Services with internal access,
- Usage of Repositories in the Application Services
- To register the services in main program, we have to declare composition root.
Infrastructure
- Consists of implementation of Repositories and Unit Of Work with internal access, which can be changed easily,in the future so business logic wont get change, because the application layer work with abstractions.
- To register the repositories in main program we have to declare composition root.
Controller
- Uses the Register method from application layer and infrastructure layer.
Let we see this with example.
Domain:
Application or Use Case:
Infrastructure Layer:
Controllers:
From this article you can learn a example of how to implement the Repository pattern and Unit Of Work.