mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
- 优化 fsql.Transaction 线程事务;
This commit is contained in:
@ -74,16 +74,19 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
private void CommitTransaction(bool isCommit, Transaction2 tran, Exception rollbackException, string remark = null)
|
||||
{
|
||||
if (tran == null || tran.Transaction == null || tran.Transaction.Connection == null) return;
|
||||
if (tran == null || tran.Transaction == null || tran.Connection == null) return;
|
||||
_trans.TryRemove(tran.Connection.LastGetThreadId, out var oldtran);
|
||||
|
||||
Exception ex = null;
|
||||
if (string.IsNullOrEmpty(remark)) remark = isCommit ? "提交" : "回滚";
|
||||
try
|
||||
{
|
||||
Trace.WriteLine($"线程{tran.Connection.LastGetThreadId}事务{remark}");
|
||||
if (isCommit) tran.Transaction.Commit();
|
||||
else tran.Transaction.Rollback();
|
||||
if (tran.Transaction.Connection != null) //用户自行 Commit、Rollback
|
||||
{
|
||||
Trace.WriteLine($"线程{tran.Connection.LastGetThreadId}事务{remark}");
|
||||
if (isCommit) tran.Transaction.Commit();
|
||||
else tran.Transaction.Rollback();
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
|
Reference in New Issue
Block a user