This commit is contained in:
sunkaixuan 2025-03-17 09:29:27 +08:00
parent f5a136c4be
commit 8cb06ce9af
2 changed files with 59 additions and 0 deletions

View File

@ -33,6 +33,7 @@ namespace OrmTest
}
public static void Init()
{
Unitsadfadsayss.Init();
Unitadfsa1ysfds.Init();
Unitdsadfays.Init();
UnitDADF231YAA.Init();

View File

@ -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<Test001>();
//清空表
//db.DbMaintenance.TruncateTable<Test001>();
//插入测试数据
var result = db.Insertable(new Test001()).ExecuteCommand();//用例代码
var xxx = db.Queryable<Test001>().ToList();
if (xxx.First().test6 != 2)
{
throw new Exception("unit error");
}
db.CodeFirst.InitTables<TEST001>();
var xxx2 = db.Queryable<TEST001>().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; }
}
}