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
8537cbef73
commit
4957fb23e9
@ -48,6 +48,44 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
throw new Exception("unit error");
|
throw new Exception("unit error");
|
||||||
}
|
}
|
||||||
|
db.CodeFirst.InitTables<UnitUpdateColumns>();
|
||||||
|
db.DbMaintenance.TruncateTable<UnitUpdateColumns>();
|
||||||
|
db.Insertable(new UnitUpdateColumns()
|
||||||
|
{
|
||||||
|
id = 1,
|
||||||
|
Name = "abc",
|
||||||
|
Time = DateTime.Now.Date
|
||||||
|
}).ExecuteCommand();
|
||||||
|
db.Insertable(new UnitUpdateColumns()
|
||||||
|
{
|
||||||
|
id = 2,
|
||||||
|
Name = "123",
|
||||||
|
Time = DateTime.Now.Date.AddDays(1)
|
||||||
|
}).ExecuteCommand();
|
||||||
|
db.DbMaintenance
|
||||||
|
.UpdateColumn("UnitUpdateColumns",new DbColumnInfo() {
|
||||||
|
DbColumnName="Name",
|
||||||
|
DataType="text",
|
||||||
|
});
|
||||||
|
var data=db.Queryable<UnitUpdateColumns>().ToList();
|
||||||
|
if (data[0].Name != "abc" || data[1].Name != "123")
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
var columns=db.DbMaintenance.GetColumnInfosByTableName("UnitUpdateColumns", false);
|
||||||
|
if (columns[2].DataType.ToLower() != "text")
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
db.DbMaintenance.DropTable("UnitUpdateColumns");
|
||||||
|
}
|
||||||
|
public class UnitUpdateColumns
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey =true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public DateTime Time { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UnitDropColumnTest
|
public class UnitDropColumnTest
|
||||||
|
Loading…
Reference in New Issue
Block a user