Open
Description
使用MySqlConnector驱动
创建UnitOfWork事务
在提交时将数据库重启,再次使用此连接会提示 Transactions may not be nested.
建议 UnitOfWork 还回对象时 若事务不为空 将对象释放
// 原代码:
void ReturnObject()
{
if (string.IsNullOrEmpty(this.Id) == false && DebugBeingUsed.TryRemove(this.Id, out var old))
this.Id = null;
_fsql.Ado.MasterPool.Return(_conn);
_tran = null;
_conn = null;
EntityChangeReport?.Report.Clear();
}
// 调整后:
void ReturnObject()
{
if (string.IsNullOrEmpty(this.Id) == false && DebugBeingUsed.TryRemove(this.Id, out var old))
this.Id = null;
_fsql.Ado.MasterPool.Return(_conn);
_tran?.Dispose();
_tran = null;
_conn = null;
EntityChangeReport?.Report.Clear();
}
Metadata
Metadata
Assignees
Labels
No labels