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.

  1. Add a Rollback void to his IUnitOfWork
  2. Implement the new method in the concrete class
  3. 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!

Was it helpful?

Solution

RollBack is implicit. When the transactionScope is disposed without calling the Complete method, it rollbacks the transaction

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top