mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add demo
This commit is contained in:
parent
f5a136c4be
commit
8cb06ce9af
@ -33,6 +33,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
Unitsadfadsayss.Init();
|
||||
Unitadfsa1ysfds.Init();
|
||||
Unitdsadfays.Init();
|
||||
UnitDADF231YAA.Init();
|
||||
|
@ -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; }
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user