Skip to content

Commit c30be33

Browse files
committed
optimize ReleaseTransaction
1 parent 97e6c0b commit c30be33

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SmartSql/DbSession/DefaultDbSession.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ public void CommitTransaction()
215215
}
216216

217217
Transaction.Commit();
218-
ReleaseTransaction();
219218
Committed?.Invoke(this, DbSessionEventArgs.None);
220219

221220
#endregion
@@ -227,6 +226,10 @@ public void CommitTransaction()
227226
_diagnosticListener.WriteDbSessionCommitError(operationId, this, ex);
228227
throw;
229228
}
229+
finally
230+
{
231+
ReleaseTransaction();
232+
}
230233
}
231234

232235
public void RollbackTransaction()
@@ -255,7 +258,6 @@ public void RollbackTransaction()
255258
}
256259

257260
Transaction.Rollback();
258-
ReleaseTransaction();
259261
Rollbacked?.Invoke(this, DbSessionEventArgs.None);
260262

261263
#endregion
@@ -267,6 +269,10 @@ public void RollbackTransaction()
267269
_diagnosticListener.WriteDbSessionRollbackError(operationId, this, ex);
268270
throw;
269271
}
272+
finally
273+
{
274+
ReleaseTransaction();
275+
}
270276
}
271277

272278
private void ReleaseTransaction()

0 commit comments

Comments
 (0)