What is the UnitofWork in the Repository Pattern

 What is the Unit of Work in the Repository Pattern?

Unit of Work in the repository 

means a single transaction can include multiple operations like Update, Insert or Delete on multiple tables at the same time as the "Save Changes" method of Entity Framework.

What is the Unit of Work in the Repository Pattern | godevstack.com


At this time, Another question is Why we need to use the Unit of Work in the Repository Design Pattern while the Entity framework has all in the DbContext?

The answer is that it is designed to accommodate future technological changes. Imagine if you use DBContext entirely if you want to change data storage from MS SQL later. SERVER to MongoDB or any type of Database you want.

The Cons of don't use the Unit of Work and Repository design pattern

       You must change all from the DB to the Business logic.

The Pros of using the Unit of Work and Repository design pattern

       You only change the DbContext and repository, about the Bussiness logic don't need to change or very small change.


I hope it can help.

GoDevStack.com










Post a Comment

Thank for leaving message

أحدث أقدم
managed wordpress hosting
managed wordpress hosting