TransactionScope with multiple StoredProcedures

1

I'm thinking of implementing TransactionScope in my code, however, all bank accesses are done by StoredProcedures .

Can TransactionScope be able to give rollback in multiple actions performed in StoredProcedures ?

using (var trans = new TransactionScope()) {
  try {
    this.Teste1Repository.Insert(); //  Chamada a primeira PROC
    this.Teste2Repository.Insert(); //  Chamada a segunda PROC

    trans.Complete();
  }
  catch {
  //  Trata erro
  }
}
    
asked by anonymous 10.10.2017 / 16:46

1 answer

2

If the first StoredProcedure SP1 issues a commit, any changes that have already been made will be permanent. In this case, if SP2 fails, the changes made by SP1 will not be rolled back.

Or you control the operations of your system via Code, or via Database.

If you want to control RollBacks via code, you will have to rewrite the whole function of the Procedure to C #.

Source: Own experience.

EDIT 1: Test this concept using SQLCommand of C #. link

    
10.10.2017 / 22:43