none
Bypass TransactionScope RRS feed

  • Question

  • Is there any way of having an update/insert/delete not be part of a transactionscope ?

     

    here's an example that..  

     firstly updates ELEMENT.Name with "a"

     then calls SubWork which updates KEY_ALLOCATION.column_content with "c"

     then updates ELEMENT_TRANS.description with "b"

     

     how can I make the SubWork() update always happen outside of the transaction.  (the subroutine actually updates a table and returns a value which needs to be inserted into the element trans table, but has to be unique so has to be single user, and no we can't use an identity column)

     

            Using ts As New TransactionScope
                Dim DC As New DBdc

                Dim Elem = From i In DC.ELEMENT
                For Each Row In Elem
                    Row.name = "a"
                Next
                DC.SubmitChanges()

                SubWork()

                Dim ETran = DC.ELEMENT_TRANS
                For Each Row In ETran
                    Row.description = "b"
                Next
                DC.SubmitChanges()

                ts.Complete()
            End Using

     

        Private Sub SubWork()
            Dim DC As New DBdc
            Dim KA = From i In DC.KEY_ALLOCATION
            For Each Row In KA
                Row.column_content = "c"
            Next
            DC.SubmitChanges()
        End Sub

    Tuesday, October 14, 2008 5:08 PM

Answers

  • Wrap your "SubWork" thingie in a new transactionscope with the scopeOption param set to RequiresNew. That way whatever happens in it will be done in its own separate transaction.

     

    new TransactionScope(TransactionScopeOption.RequiresNew, ....etc...

     

    Wednesday, October 15, 2008 12:32 AM
    Answerer

All replies

  • Wrap your "SubWork" thingie in a new transactionscope with the scopeOption param set to RequiresNew. That way whatever happens in it will be done in its own separate transaction.

     

    new TransactionScope(TransactionScopeOption.RequiresNew, ....etc...

     

    Wednesday, October 15, 2008 12:32 AM
    Answerer
  • Many thanks, just cheered me up no end on a wet dreary Monday morning after getting back from vacation.

    Monday, October 20, 2008 8:16 AM