From 175341cc2f52d6e39307964d2c43aab94ff58e67 Mon Sep 17 00:00:00 2001
From: sunkaixuna <610262374@qq.com>
Date: Tue, 23 Nov 2021 17:37:37 +0800
Subject: [PATCH] Add unit test
---
.../SqlServerTest/SqlServerTest.csproj | 1 +
Src/Asp.Net/SqlServerTest/UnitTest/Main.cs | 2 +-
.../SqlServerTest/UnitTest/UFastest.cs | 63 +++++++++++++++++++
3 files changed, 65 insertions(+), 1 deletion(-)
create mode 100644 Src/Asp.Net/SqlServerTest/UnitTest/UFastest.cs
diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
index 113c35948..806c090e0 100644
--- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
+++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
@@ -94,6 +94,7 @@
+
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs
index 9bff8c6da..62de4e94d 100644
--- a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs
@@ -31,7 +31,7 @@ namespace OrmTest
}
public static void Init()
{
-
+ Fastest2();
SplitTest();
Filter();
Insert();
diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UFastest.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UFastest.cs
new file mode 100644
index 000000000..c4b2633bf
--- /dev/null
+++ b/Src/Asp.Net/SqlServerTest/UnitTest/UFastest.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using SqlSugar;
+
+namespace OrmTest
+{
+ public partial class NewUnitTest
+ {
+ private static void Fastest2()
+ {
+ var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
+ {
+ ConnectionString =Config.ConnectionString,
+ DbType = DbType.PostgreSQL,
+ IsAutoCloseConnection = true
+ });
+
+ db.CodeFirst.InitTables();
+
+ //用例代码
+ db.Insertable(new Test2() { p = "1" }).ExecuteCommand();//用例代码
+
+ db.Insertable(new Test2() { p = "2", delPer = 1 }).ExecuteCommand();//用例代码
+
+ var updateList = db.Queryable()
+ .ToList();
+
+ db.Fastest().BulkCopy(updateList);
+
+ int index = 0;
+
+ foreach (var update in updateList)
+ {
+ update.p = index.ToString();
+
+ index++;
+ }
+
+ db.Fastest().BulkUpdate(updateList);
+
+ Console.WriteLine("用例跑完");
+ Console.ReadKey();
+ }
+
+ [SugarTable("UnitFastest001a")]
+ public class Test2
+ {
+ [SugarColumn(IsNullable = false, IsPrimaryKey = true)]
+ public int id { get; set; }
+
+ [SugarColumn(IsNullable = false)]
+ public string p { get; set; }
+
+ [SugarColumn(IsNullable = true)]
+ public int? delPer { get; set; }
+
+ [SugarColumn(IsNullable = true)]
+ public DateTime? del_Time { get; set; }
+ }
+ }
+}
\ No newline at end of file