diff --git a/Mehdime.Entity/Implementations/DbContextCollection.cs b/Mehdime.Entity/Implementations/DbContextCollection.cs index 578790e..48ae7a1 100644 --- a/Mehdime.Entity/Implementations/DbContextCollection.cs +++ b/Mehdime.Entity/Implementations/DbContextCollection.cs @@ -126,6 +126,7 @@ public int Commit() { tran.Commit(); tran.Dispose(); + _transactions.Remove(dbContext); } } catch (Exception e) @@ -134,11 +135,10 @@ public int Commit() } } - _transactions.Clear(); - _completed = true; - if (lastError != null) lastError.Throw(); // Re-throw while maintaining the exception's original stack track + else + _completed = true; return c; } @@ -178,6 +178,7 @@ public async Task CommitAsync(CancellationToken cancelToken) { tran.Commit(); tran.Dispose(); + _transactions.Remove(dbContext); } } catch (Exception e) @@ -186,11 +187,10 @@ public async Task CommitAsync(CancellationToken cancelToken) } } - _transactions.Clear(); - _completed = true; - if (lastError != null) lastError.Throw(); // Re-throw while maintaining the exception's original stack track + else + _completed = true; return c; }