RollBack is implicit. When the transactionScope
is disposed without calling the Complete
method, it rollbacks the transaction
UnitOfWork TransactionScope rollback
-
29-08-2022 - |
Question
I am following this guys tut Repository Pattern and Unit of Work with Entity Framework in ASP.NET MVC to learn how to use the repo pattern in conjunction with the Unit of Work pattern.
It's a nice simple tut and explains things but there is one thing that had me stumped: Why in his UnitOfWork does he not have a Rollback method.
At first I thought: "Ha, the silly guy just forgot to do that, no worries ill just do it myself.
- Add a Rollback void to his IUnitOfWork
- Implement the new method in the concrete class
- In the new method just go _transaction.Rollback
but then thats when I realise that TransactionScope doesn't do rollbacks.
Is there something I am missing? Or are Rollbacks not necessary? Won't I then be left with reserved records in my db until they are eventually garbage collected?
Thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow