From 4b2c2263a2cc8fb6bc538f9573530c50052f97bf Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 31 May 2022 11:55:15 +0800 Subject: [PATCH] Update .net framework --- .../Abstract/FastestProvider/FastestProvider.cs | 11 +++++++++++ .../ExpressionsToSql/Common/SugarParameter.cs | 12 ++++++++++++ Src/Asp.Net/SqlSugar/Interface/IFastest.cs | 2 ++ Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs | 3 +++ 4 files changed, 28 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs index 57896ca2a..10e9a6b25 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs @@ -29,6 +29,11 @@ namespace SqlSugar Check.ExceptionEasy(this.AsName.IsNullOrEmpty(), "need .AS(tablaeName) ", "需要 .AS(tablaeName) 设置表名"); return BulkCopyAsync(this.AsName, dt).ConfigureAwait(true).GetAwaiter().GetResult(); } + public Task BulkCopyAsync(DataTable dt) + { + Check.ExceptionEasy(this.AsName.IsNullOrEmpty(), "need .AS(tablaeName) ", "需要 .AS(tablaeName) 设置表名"); + return BulkCopyAsync(this.AsName, dt); + } public async Task BulkCopyAsync(string tableName, DataTable dt) { if (Size > 0) @@ -115,6 +120,12 @@ namespace SqlSugar Check.ExceptionEasy(this.AsName.IsNullOrEmpty(), "need .AS(tablaeName) ", "需要 .AS(tablaeName) 设置表名"); return BulkUpdateAsync(this.AsName, dataTable, whereColumns, updateColumns).ConfigureAwait(true).GetAwaiter().GetResult(); } + public Task BulkUpdateAsync(DataTable dataTable, string[] whereColumns) + { + string[] updateColumns = dataTable.Columns.Cast().Select(it => it.ColumnName).Where(it => !whereColumns.Any(z => z.EqualCase(it))).ToArray(); + Check.ExceptionEasy(this.AsName.IsNullOrEmpty(), "need .AS(tablaeName) ", "需要 .AS(tablaeName) 设置表名"); + return BulkUpdateAsync(this.AsName, dataTable, whereColumns, updateColumns); + } public async Task BulkUpdateAsync(string tableName, DataTable dataTable, string[] whereColumns, string[] updateColumns) { diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs index 4a130ab10..0e6baeb18 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs @@ -138,6 +138,18 @@ namespace SqlSugar this.DbType = System.Data.DbType.Int64; this.Value = Convert.ToInt64(Value); } + else if (type==UtilConstants.UIntType) + { + this.DbType = System.Data.DbType.UInt32; + } + else if (type == UtilConstants.ULongType) + { + this.DbType = System.Data.DbType.UInt64; + } + else if (type == UtilConstants.ShortType) + { + this.DbType = System.Data.DbType.UInt16; + } } public SugarParameter(string name, object value, bool isOutput) diff --git a/Src/Asp.Net/SqlSugar/Interface/IFastest.cs b/Src/Asp.Net/SqlSugar/Interface/IFastest.cs index 34eac10bc..81ebe5d67 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IFastest.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IFastest.cs @@ -18,6 +18,7 @@ namespace SqlSugar int BulkCopy(string tableName,DataTable dataTable); int BulkCopy(DataTable dataTable); Task BulkCopyAsync(string tableName, DataTable dataTable); + Task BulkCopyAsync(DataTable dataTable); int BulkUpdate(List datas); Task BulkUpdateAsync(List datas); @@ -27,6 +28,7 @@ namespace SqlSugar int BulkUpdate(DataTable dataTable, string[] whereColumns, string[] updateColumns); int BulkUpdate(DataTable dataTable, string[] whereColumns); Task BulkUpdateAsync(string tableName, DataTable dataTable, string[] whereColumns, string[] updateColumns); + Task BulkUpdateAsync(DataTable dataTable, string[] whereColumns); SplitFastest SplitTable(); } } diff --git a/Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs b/Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs index ea751c3b4..6387f7f01 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/UtilConstants.cs @@ -15,6 +15,9 @@ namespace SqlSugar internal const string ReplaceKey = "{662E689B-17A1-4D06-9D27-F29EAB8BC3D6}"; internal const string ReplaceCommaKey = "{112A689B-17A1-4A06-9D27-A39EAB8BC3D5}"; + internal static Type UShortType = typeof(ushort); + internal static Type ULongType = typeof(ulong); + internal static Type UIntType = typeof(uint); internal static Type IntType = typeof(int); internal static Type LongType = typeof(long); internal static Type GuidType = typeof(Guid);