コード例 #1
0
 /// <summary>
 /// Rollbacks the transaction to the database and closes the connection.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 public static void RollbackTransaction(RepositoryTransaction transaction)
 {
     try
     {
         if (transaction != null && transaction.Transaction != null)
         {
             transaction.Transaction.Rollback();
             transaction.Transaction.Dispose();
         }
     }
     catch (Exception e)
     {
         throw new RepositoryException("BaseRepository::RollbackTransaction: Unable to rollback transaction", e);
     }
 }
コード例 #2
0
 /// <summary>
 /// Opens a Simple.Data connection.
 /// </summary>
 /// <returns></returns>
 internal static Simple.Data.DataStrategy OpenConnection(RepositoryTransaction transaction = null)
 {
     try
     {
         return transaction != null ? transaction.Transaction : Simple.Data.Database.OpenConnection(ActiveConnection.ConnectionString, ActiveConnection.Provider);
     }
     catch (Exception e)
     {
         throw new RepositoryException($"Unable to open connection: {ActiveConnection?.ConnectionString ?? string.Empty} provider: {ActiveConnection?.Provider ?? string.Empty}", e);
     }
 }
コード例 #3
0
 /// <summary>
 /// Commits the transaction to the database, and closes the connection.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 public static void CommitTransaction(RepositoryTransaction transaction)
 {
     try
     {
         transaction.Transaction.Commit();
         transaction.Transaction.Dispose();
     }
     catch (Exception e)
     {
         throw new RepositoryException("BaseRepository::CommitTransaction: Unable to commit transaction", e);
     }
 }