/// <summary>
 /// NOTE: Rolls back all transactions across all connections
 /// Also, resets all sequences
 /// </summary>
 public void Rollback()
 {
     _trans.Rollback();
     SqlExecutor.Execute(DbConnection.ConnectionString, $"IF EXISTS (SELECT * FROM sys.sysprocesses WHERE open_tran = 1) BEGIN ALTER DATABASE {DbConnection.Database} SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE {DbConnection.Database} SET MULTI_USER; END");
     TransactionState = TransactionState.RolledBack;
     SequenceResetter.ResetAllSequences(DbConnection.ConnectionString);
 }
예제 #2
0
 public static void ResetAllSequences(string connectionString)
 {
     SqlExecutor.Execute(connectionString, sql);
 }
예제 #3
0
 /// <summary>
 /// Resets all sequence values in a database.  The
 /// method uses the INFORMATION_SCHEMA schema to
 /// identify all sequences.  These sequences are
 /// reset to 1 plus the maximum value of the
 /// column that uses the sequence's next value as
 /// a default.  Note: This method may fail if
 /// the same sequence is used for multiple tables.
 /// </summary>
 /// <param name="context">Valid db context</param>
 public static void ResetAllSequences(DbContext context)
 {
     SqlExecutor.Execute(context, sql);
 }