Sunday, October 30, 2016

Database transactions


Database transaction with deferent function

private static bool UpdateFacility(int id,string name)
        {
            using (var con = DatabaseInfo.WebServiceConnectionFactory)
            {
                con.Open();
                using (var transaction = con.BeginTransaction())
                {

                    try
                    {
                      UpdateFirst(id,name, con, transaction);
     UpdateSecond(id,name, con, transaction);
      transaction.commit();
                    }
                    catch  
                    {
                        transaction.Rollback();
                         throw;

                    }
                }
            }
 }
 
 private static void UpdateFirst(int id,string name, IDbConnection con, IDbTransaction transaction){
 
try{
con.Execute('update quary',transaction);
}catch{throw;}
 
 }
 
 private static void UpdateSecond(int id,string name, IDbConnection con, IDbTransaction transaction){
 try{
con.Execute('update quary',transaction);
}catch{throw;}
 
 }

No comments:

Post a Comment

Sql server row level policy