mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add unit test
This commit is contained in:
parent
4f09dc51be
commit
2a3761542a
46
Src/Asp.NetCore2/DmOrmTest/UnitTest/UnitInsert.cs
Normal file
46
Src/Asp.NetCore2/DmOrmTest/UnitTest/UnitInsert.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
internal class UnitInsert
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = NewUnitTest.Db;
|
||||
db.CodeFirst.InitTables<Unitadfa>();
|
||||
db.Insertable(new Unitadfa()
|
||||
{
|
||||
Name = "A",
|
||||
Date = DateTime.Now,
|
||||
}).ExecuteCommand();
|
||||
db.Insertable(new List<Unitadfa>() {
|
||||
new Unitadfa()
|
||||
{
|
||||
Name = "A",
|
||||
Date = DateTime.Now,
|
||||
},
|
||||
new Unitadfa()
|
||||
{
|
||||
Name = "A",
|
||||
Date = DateTime.Now,
|
||||
}}).ExecuteCommand();
|
||||
var list=db.Queryable<Unitadfa>().ToList();
|
||||
db.DbMaintenance.TruncateTable<Unitadfa>();
|
||||
db.Fastest<Unitadfa>().OffIdentity().BulkCopy(list);
|
||||
|
||||
db.DbMaintenance.DropTable<Unitadfa>();
|
||||
|
||||
}
|
||||
}
|
||||
public class Unitadfa
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsIdentity =true,IsPrimaryKey =true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
[SqlSugar.SugarColumn(ColumnDataType ="Date")]
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user