The following code executes one stored procedure. A stored procedure contains only one command. Is there any use to wrapping everything into a transaction, even if it has only one SQL statement (or one stored proc that has only one sql statement)?
In the following code example, if the deletion failed, it fails. Nothing more to roll back (it seems). So why is everything in a transaction?
using (ITransactionManager transMan = repository.TransactionManager())
using (IController controller = repository.Controller())
{
transMan.BeginTransaction();
try
{
controller.Delete(id);
transMan.CommitTransaction();
}
catch
{
transMan.RollbackTransaction();
throw;
}
}
source
share