fix: 修复dispose 不生效的问题

main
NoahLan 7 months ago
parent f67d054aae
commit 6ce4bf3fa3

@ -1,33 +1,34 @@
using NPin.Framework.SqlSugarCore.Abstractions; using NPin.Framework.SqlSugarCore.Abstractions;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace NPin.Framework.SqlSugarCore.Uow; namespace NPin.Framework.SqlSugarCore.Uow;
public class SqlSugarTransactionApi : ITransactionApi, ISupportsRollback public class SqlSugarTransactionApi : ITransactionApi, ISupportsRollback
{ {
private ISqlSugarDbContext _sqlSugarDbContext; private ISqlSugarDbContext _sqlSugarDbContext;
public SqlSugarTransactionApi(ISqlSugarDbContext sqlSugarDbContext) public SqlSugarTransactionApi(ISqlSugarDbContext sqlSugarDbContext)
{ {
_sqlSugarDbContext = sqlSugarDbContext; _sqlSugarDbContext = sqlSugarDbContext;
} }
public ISqlSugarDbContext GetDbContext() public ISqlSugarDbContext GetDbContext()
{ {
return _sqlSugarDbContext; return _sqlSugarDbContext;
} }
public void Dispose() public void Dispose()
{ {
} _sqlSugarDbContext.SqlSugarClient.Ado.Dispose();
}
public async Task CommitAsync(CancellationToken cancellationToken = default)
{ public async Task CommitAsync(CancellationToken cancellationToken = default)
await _sqlSugarDbContext.SqlSugarClient.Ado.CommitTranAsync(); {
} await _sqlSugarDbContext.SqlSugarClient.Ado.CommitTranAsync();
}
public async Task RollbackAsync(CancellationToken cancellationToken = default)
{ public async Task RollbackAsync(CancellationToken cancellationToken = default)
await _sqlSugarDbContext.SqlSugarClient.Ado.RollbackTranAsync(); {
} await _sqlSugarDbContext.SqlSugarClient.Ado.RollbackTranAsync();
}
} }
Loading…
Cancel
Save