コード例 #1
0
 public IDbTransaction BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
 {
     try
     {
         _semaphore.Wait();
         if (CurrentTransaction != null)
         {
             throw new InvalidOperationException("Transaction already in progress!");
         }
         CurrentTransaction = new DbTransactionWrapper()
                              .WithIsolationLevel(isolationLevel)
                              .WithOnDispose(() => CurrentTransaction = null);
         return(CurrentTransaction);
     }
     finally
     {
         _semaphore.Release();
     }
 }
コード例 #2
0
 public void Dispose()
 {
     CurrentTransaction?.Dispose();
     CurrentTransaction = null;
     _semaphore?.Dispose();
 }