From efcd0b5cacac6e334d0ec0a9e92c302301a61e17 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 10 May 2023 16:00:58 +0800 Subject: [PATCH] Update DatasTrackingExecommand --- .../Abstract/UpdateProvider/UpdateableHelper.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs index 51bcf095c..c879ac94c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs @@ -19,9 +19,10 @@ namespace SqlSugar private int DatasTrackingExecommand() { var trakRows = 0; + var isNoTran = this.Context.Ado.IsNoTran(); try { - if (this.Context.Ado.IsNoTran()) + if (isNoTran) { this.Context.Ado.BeginTran(); } @@ -40,14 +41,14 @@ namespace SqlSugar } ++i; } - if (this.Context.Ado.IsNoTran()) + if (isNoTran) { this.Context.Ado.CommitTran(); } } catch (Exception) { - if (this.Context.Ado.IsNoTran()) + if (isNoTran) { this.Context.Ado.RollbackTran(); } @@ -57,10 +58,11 @@ namespace SqlSugar } private async Task DatasTrackingExecommandAsync() { + var isNoTran = this.Context.Ado.IsNoTran(); var trakRows = 0; try { - if (this.Context.Ado.IsNoTran()) + if (isNoTran) { await this.Context.Ado.BeginTranAsync(); } @@ -79,14 +81,14 @@ namespace SqlSugar } ++i; } - if (this.Context.Ado.IsNoTran()) + if (isNoTran) { await this.Context.Ado.CommitTranAsync(); } } catch (Exception) { - if (this.Context.Ado.IsNoTran()) + if (isNoTran) { await this.Context.Ado.RollbackTranAsync(); }