Repository Pattern Simple
This package was written in .NET 5.0
There are 2 base classes and 2 interface
GenericRepo
UnitOfWork
IGenericRepo
IUnitOfWork
This a ASP NET CORE WEB API project
I organized the file like the image below
I conntected with my database and generated 3 classes in Models directory based on my databse
- Course
- Enrollment
- AppContext
We'll create a directory with name is Repositories
We'll create a classes named CoursesRepo implemented from GenericRepo based class
The EnrollmentsRepo class is same for the CoursesRepo class
Default GenericRepo includes methods:
Get
GetAsync
GetAll
GetAllAsync
Add
AddAsync
Update
UpdateAsync
Remove
RemoveAsync
If you want to add or modify the above methods, you can override
them.
We create a interface ICourseUnitOfWork
inherit from IUnitOfWork
interface
We also create a class CourseUnitOfWork implemented UnitOfWork
base class and ICourseUnitOfWork
interface
If you want to add or modify the above methods, you can override
them.