Dapper - Unit of work between 2 repositories
I need to keep a common transaction between 2 repositories, but I'm not sure who will be responsible for rolling it back in case of failure.
Those 2 repositories do share connection and transaction via parent, but one of them has to commit the transaction.
How do people usually go about this?
Those 2 repositories do share connection and transaction via parent, but one of them has to commit the transaction.
How do people usually go about this?
- Do I make it so that the service is responsible for coordinating the repositories? I'm too new but this sounds wrong because a transaction commit/rollback is the responsibility of the database layer.
- Do I call one repository method through another? This would mean injecting a repository, and I read that it's bad practice.