From c9a7e4ad374ac4c22d652ba6b4d73453c543680f Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Sun, 21 Nov 2021 12:50:58 +0800 Subject: [PATCH] Update unit test --- .../SqlSeverTest/UnitTest/UBulkCopy.cs | 30 +++++++++++++++++++ .../FastestProvider/FastestProvider.cs | 2 ++ 2 files changed, 32 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSeverTest/UnitTest/UBulkCopy.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSeverTest/UnitTest/UBulkCopy.cs index a16840647..0d6c49cb2 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSeverTest/UnitTest/UBulkCopy.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSeverTest/UnitTest/UBulkCopy.cs @@ -56,8 +56,38 @@ namespace OrmTest { throw new Exception("unit Bulk"); } + + Db.CodeFirst.InitTables(); + Db.DbMaintenance.TruncateTable(); + var count=Db.Fastest().AS("UnitIdentity111").BulkCopy(new List { + new UnitIdentity111111111(){ Id=1, Name="jack" } + }); + if (count == 0) + { + throw new Exception("unit Bulk"); + } + count = Db.Fastest().AS("UnitIdentity111").BulkUpdate(new List { + new UnitIdentity111111111(){ Id=1, Name="jack" } + }); + if (count == 0) + { + throw new Exception("unit Bulk"); + } } } + + public class UnitIdentity111 + { + public int Id { get; set; } + public string Name { get; set; } + } + public class UnitIdentity111111111 + { + [SqlSugar.SugarColumn(IsPrimaryKey = true)] + public int Id { get; set; } + public string Name { get; set; } + } + public class UnitIdentity1 { [SqlSugar.SugarColumn(IsPrimaryKey =true,IsIdentity =true)] diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/FastestProvider.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/FastestProvider.cs index 3d1f7edd3..e5a85fc74 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/FastestProvider.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/FastestProvider/FastestProvider.cs @@ -80,6 +80,8 @@ namespace SqlSugar private async Task _BulkUpdate(List datas, string[] whereColumns, string[] updateColumns) { Begin(datas); + Check.Exception(whereColumns == null || whereColumns.Count() == 0, "where columns count=0"); + Check.Exception(updateColumns == null || updateColumns.Count() == 0, "set columns count=0"); var isAuto = this.context.CurrentConnectionConfig.IsAutoCloseConnection; this.context.CurrentConnectionConfig.IsAutoCloseConnection = false; DataTable dt = ToDdateTable(datas);