From 6ce4bf3fa3b39134a491f9df43389780b180eb24 Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Wed, 10 Apr 2024 15:11:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Ddispose=20=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Uow/SqlSugarTransactionApi.cs | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/framework/NPin.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs b/framework/NPin.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs index 29b10f9..f5c5e6b 100644 --- a/framework/NPin.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs +++ b/framework/NPin.Framework.SqlSugarCore/Uow/SqlSugarTransactionApi.cs @@ -1,33 +1,34 @@ -using NPin.Framework.SqlSugarCore.Abstractions; -using Volo.Abp.Uow; - -namespace NPin.Framework.SqlSugarCore.Uow; - -public class SqlSugarTransactionApi : ITransactionApi, ISupportsRollback -{ - private ISqlSugarDbContext _sqlSugarDbContext; - - public SqlSugarTransactionApi(ISqlSugarDbContext sqlSugarDbContext) - { - _sqlSugarDbContext = sqlSugarDbContext; - } - - public ISqlSugarDbContext GetDbContext() - { - return _sqlSugarDbContext; - } - - public void Dispose() - { - } - - public async Task CommitAsync(CancellationToken cancellationToken = default) - { - await _sqlSugarDbContext.SqlSugarClient.Ado.CommitTranAsync(); - } - - public async Task RollbackAsync(CancellationToken cancellationToken = default) - { - await _sqlSugarDbContext.SqlSugarClient.Ado.RollbackTranAsync(); - } +using NPin.Framework.SqlSugarCore.Abstractions; +using Volo.Abp.Uow; + +namespace NPin.Framework.SqlSugarCore.Uow; + +public class SqlSugarTransactionApi : ITransactionApi, ISupportsRollback +{ + private ISqlSugarDbContext _sqlSugarDbContext; + + public SqlSugarTransactionApi(ISqlSugarDbContext sqlSugarDbContext) + { + _sqlSugarDbContext = sqlSugarDbContext; + } + + public ISqlSugarDbContext GetDbContext() + { + return _sqlSugarDbContext; + } + + public void Dispose() + { + _sqlSugarDbContext.SqlSugarClient.Ado.Dispose(); + } + + public async Task CommitAsync(CancellationToken cancellationToken = default) + { + await _sqlSugarDbContext.SqlSugarClient.Ado.CommitTranAsync(); + } + + public async Task RollbackAsync(CancellationToken cancellationToken = default) + { + await _sqlSugarDbContext.SqlSugarClient.Ado.RollbackTranAsync(); + } } \ No newline at end of file