mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add user test case
This commit is contained in:
parent
111c6a60fb
commit
b7b1d3e430
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
UnitTest.Init();
|
||||||
Unitdfasfasfa.Init();
|
Unitdfasfasfa.Init();
|
||||||
UnitAddRemark.Init();
|
UnitAddRemark.Init();
|
||||||
UnitSplitTask.Init();
|
UnitSplitTask.Init();
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
internal class UnitTest
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
db.CodeFirst.SetStringDefaultLength(200)
|
||||||
|
.SplitTables()
|
||||||
|
.InitTables(typeof(tb_test));
|
||||||
|
db.Insertable(new tb_test
|
||||||
|
{
|
||||||
|
Key = "123"
|
||||||
|
})
|
||||||
|
.SplitTable()
|
||||||
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
var rows=db.Updateable(new tb_test
|
||||||
|
{
|
||||||
|
Id=Guid.NewGuid(),
|
||||||
|
Key = "123",
|
||||||
|
Value = "901"
|
||||||
|
})
|
||||||
|
.WhereColumns(c => c.Key)
|
||||||
|
.UpdateColumns(c => c.Value)
|
||||||
|
.SplitTable()
|
||||||
|
.ExecuteCommand();
|
||||||
|
if (rows == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[SplitTable(SplitType.Day)] //需要这里取消并InitTables时不用SplitTables(),SetStringDefaultLength才会生效
|
||||||
|
[SugarTable("tb_test_{year}{month}{day}")]
|
||||||
|
public class tb_test
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string Key { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user