From a7afe09ac17aeb1ac6fe3b23c5afbd711ebdafc5 Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 13 Sep 2023 15:15:57 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9transa?= =?UTF-8?q?ction=20scope=20=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implement/NiagaraDataSynchronizeRepository.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index fe49b52..cce94f4 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -1199,8 +1199,8 @@ SET FOREIGN_KEY_CHECKS = 1;"; //} #endregion - StringBuilder sb = new StringBuilder(); + int count = 0; #region 放入import_niagara_item資料表 foreach (var row in ds) { @@ -1221,6 +1221,16 @@ device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, d row.isHistory + ", now() " + ");"; sb.Append(ss); + count++; + if (count == 100) + { + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } + sb.Clear(); + count = 0; + } } if (sb.Length > 0) {