.net - In C#, how to keep three operation in Transaction? -


currently need 3 operations:

  1. write data db
  2. write file remote share folder
  3. write data acitive directory

how make 3 steps in 1 transaction ?

i google lot, , have 2 plans,

first one. use transactionscope, code

using (transactionscope scope = new transactionscope()) {     this.storeintodb();     this.writeshardfolderdata();     this.storeintoad();     scope.complete(); } 

i have no idea, code work or not, need tests that, maybe me

second one, use try-catch, code that:

  try{         this.storeintodb();     }     catch()     {         exit();     }      try{         this.writeshardfolderdata();     }     catch()     {         this.rollbackdb();       }      try{         this.storeintoad();     }     catch()     {         this.rollbackdb();         this.rollbacksharefolderdata();     } 

is there other solution scenario ?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -