GENERIC REPOSITORY
AND
UNIT OF WORK
DRY?
Don’t Repeat Yourself, means don’t repeat your code.
Use Generic Repository to implement DRY.
Repository Pattern
Mediator between BLL(Business Logic Layer) &
DAL(Data Access Layer).
Separation layer between Data and Domain Layer.
Benefits of Repository Pattern
It centralizes data logic or business logic and service
logic.
It gives a substitution point for the unit tests.
Provides a flexible architecture.
If you want to modify the data access logic or
business access logic, you don’t need to change the
repository logic
What is Generic Repository
Pattern?
◦Generally -one repository for one model to access
data.
◦What if Single Repository for all.
◦Single Repository for data access of models.
Benefits of Generic Repository
Pattern
It reduces redundancy of code.(No longer needed)
It force programmer to work using the same pattern.
It creates possibility of less error.
If you use this pattern then it is easy to maintain the
centralized data access logic.
Unit Of Work
◦The Unit of Work Class co-ordinates the work of
multiple repositories by creating a single database
context class shared by all of them.
Benefits of Unit of Work
◦There is a common Dbcontext for all repository.
◦Without Unit of Work there will be separate
DbContext object for each repository.