mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace OrmTest
|
|
{
|
|
internal class UnitBulkCopy
|
|
{
|
|
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.Insertable(new Unitadfa()
|
|
{
|
|
Name = "A",
|
|
Date = DateTime.Now,
|
|
}).ExecuteCommand();
|
|
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; }
|
|
}
|
|
}
|