From dec730190a4a36d92f5f9821f73225547abfd934 Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Mon, 22 Nov 2021 11:47:20 +0800 Subject: [PATCH] update db.Fastest --- .../SqlSugar/Abstract/FastestProvider/FastestProvider.cs | 1 + Src/Asp.Net/SqlSugar/Interface/IFastBuilder.cs | 1 + Src/Asp.Net/SqlSugar/Interface/IFastest.cs | 2 +- Src/Asp.Net/SqlSugar/OnlyNet/OracleFastBuilder.cs | 5 +++++ .../PostgreSQL/SqlBuilder/PostgreSQLFastBuilder.cs | 7 +++++-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs index 1c73d91ac..4e133d0a3 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs @@ -93,6 +93,7 @@ namespace SqlSugar var result = await buider.UpdateByTempAsync(GetTableName(), dt.TableName, updateColumns, whereColumns); this.context.DbMaintenance.DropTable(dt.TableName); this.context.CurrentConnectionConfig.IsAutoCloseConnection = isAuto; + buider.CloseDb(); End(datas); return result; } diff --git a/Src/Asp.Net/SqlSugar/Interface/IFastBuilder.cs b/Src/Asp.Net/SqlSugar/Interface/IFastBuilder.cs index 7f97478f4..2a1a3076d 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IFastBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IFastBuilder.cs @@ -13,5 +13,6 @@ namespace SqlSugar Task UpdateByTempAsync(string tableName,string tempName,string [] updateColumns,string[] whereColumns); Task ExecuteBulkCopyAsync(DataTable dt); Task CreateTempAsync(DataTable dt) where T : class, new(); + void CloseDb(); } } diff --git a/Src/Asp.Net/SqlSugar/Interface/IFastest.cs b/Src/Asp.Net/SqlSugar/Interface/IFastest.cs index d29bd0011..fc91ed6d1 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IFastest.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IFastest.cs @@ -8,7 +8,7 @@ namespace SqlSugar public interface IFastest { IFastest AS(string tableName); - + IFastest PageSize(int Size); int BulkCopy(List datas); Task BulkCopyAsync(List datas); diff --git a/Src/Asp.Net/SqlSugar/OnlyNet/OracleFastBuilder.cs b/Src/Asp.Net/SqlSugar/OnlyNet/OracleFastBuilder.cs index 25f1f20a4..c4e0487d6 100644 --- a/Src/Asp.Net/SqlSugar/OnlyNet/OracleFastBuilder.cs +++ b/Src/Asp.Net/SqlSugar/OnlyNet/OracleFastBuilder.cs @@ -16,6 +16,11 @@ namespace SqlSugar public SqlSugarProvider Context { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public void CloseDb() + { + throw new NotImplementedException(); + } + public Task CreateTempAsync(DataTable dt) where T : class, new() { throw new NotImplementedException(); diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLFastBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLFastBuilder.cs index 24567c234..f52bed1e4 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLFastBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLFastBuilder.cs @@ -44,7 +44,7 @@ namespace SqlSugar try { var identityColumnInfo = this.entityInfo.Columns.FirstOrDefault(it => it.IsIdentity); - if (identityColumnInfo!=null) + if (identityColumnInfo != null) { throw new Exception("PgSql bulkcopy no support identity"); } @@ -52,9 +52,12 @@ namespace SqlSugar } catch (Exception ex) { - base.CloseDb(); throw ex; } + finally + { + base.CloseDb(); + } return await Task.FromResult(dt.Rows.Count); }