From 8cb06ce9af8b30255fae34c7f2a63821a1ecdb9c Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 17 Mar 2025 09:29:27 +0800 Subject: [PATCH] Add demo --- .../UserTestCases/UnitTest/Main.cs | 1 + .../UnitTest/Unitdfasfasyadflaf.cs | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfasfasyadflaf.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs index ab5b42b61..14f5afc56 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs @@ -33,6 +33,7 @@ namespace OrmTest } public static void Init() { + Unitsadfadsayss.Init(); Unitadfsa1ysfds.Init(); Unitdsadfays.Init(); UnitDADF231YAA.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfasfasyadflaf.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfasfasyadflaf.cs new file mode 100644 index 000000000..bc15c85c6 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfasfasyadflaf.cs @@ -0,0 +1,58 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OrmTest +{ + public class Unitsadfadsayss + { + public static void Init() + { + var db = NewUnitTest.Db; + //建表 + db.CodeFirst.InitTables(); + //清空表 + //db.DbMaintenance.TruncateTable(); + + + //插入测试数据 + var result = db.Insertable(new Test001()).ExecuteCommand();//用例代码 + var xxx = db.Queryable().ToList(); + if (xxx.First().test6 != 2) + { + throw new Exception("unit error"); + } + db.CodeFirst.InitTables(); + var xxx2 = db.Queryable().ToList(); + if (xxx2.First().test7 != 2) + { + throw new Exception("unit error"); + } + } + } + + + //建类 + [SugarTable("UnitdaayTest0012")] + public class Test001 + { + public int id { get; set; } + [SugarColumn(ColumnName = "test6", DefaultValue = "2", IsOnlyIgnoreInsert = true)] + public double test6 { get; set; } + } + //建类 + [SugarTable("UnitdaayTest0012")] + public class TEST001 + { + public int id { get; set; } + [SugarColumn(ColumnName = "test6", DefaultValue = "2", IsOnlyIgnoreInsert = true)] + public double test6 { get; set; } + [SugarColumn(ColumnName = "test7", DefaultValue = "2", IsOnlyIgnoreInsert = true)] + public double test7 { get; set; } + } + +} +