Published on

Clean architecture and Domain Driven Design - How to handle DB Transactions

Authors

Clean architecture and Domain Driven Design - How to handle DB Transactions

Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10)

Fallback text 1

Unit of work

Fallback text 2

In this github issue we can see a good discussion about the ways we can handle it. Unfortunally we don't have a awesome way to deal with this issue, the conclusion is that the pattern Unit of Work could handle it in the best way beign a dependency of the class in the layer Use Case, probably a contract using Interfaces to make it able to be interchanged, and maybe we will need to constrair their use together with they Database/Gateway?

Fallback text 3

The unit of work class coordinates the work of multiple repositories by creating a single database context class shared by all of them.

PS 1 Database context will be used to start and resume/revert the database transactions. PS 2: Unit of work is the same code that I created to solve database transactions where it changes the database context so it will have the same in each DAO, making it possible to start/resume/revert the transaction.