Search code examples
c#asp.netweb-applicationssubsonictransactions

Using transactions with subsonic


In my web application I've to keep audit of the user actions. So whenever user takes an action I update the object on which action is taken and keep audit trail of that action.

Now If I first modify the object and then update audit trail but the audit trail fails then what?

Obviously I need to roll-back changes to modified object. I can use Sql-Transactions in simple application, but I'm using Subsonic to talk to db. How I can handle the situation?


Solution

  • Something like:

    Using ts As New System.Transactions.TransactionScope()
      Using sharedConnectionScope As New SubSonic.SharedDbConnectionScope()
    
    ' Do your individual saves here
    
    ' If all OK
          ts.Complete()
    
       End Using
    End Using