diff --git a/Src/Asp.Net/DmTest/DmTest.csproj b/Src/Asp.Net/DmTest/DmTest.csproj index e9cf88d57..3b5e1a81d 100644 --- a/Src/Asp.Net/DmTest/DmTest.csproj +++ b/Src/Asp.Net/DmTest/DmTest.csproj @@ -87,6 +87,7 @@ + diff --git a/Src/Asp.Net/DmTest/UnitTest/UnitBulkCopy.cs b/Src/Asp.Net/DmTest/UnitTest/UnitBulkCopy.cs new file mode 100644 index 000000000..d197bc141 --- /dev/null +++ b/Src/Asp.Net/DmTest/UnitTest/UnitBulkCopy.cs @@ -0,0 +1,50 @@ +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(); + db.Insertable(new Unitadfa() + { + Name = "A", + Date = DateTime.Now, + }).ExecuteCommand(); + db.Insertable(new List() { + new Unitadfa() + { + Name = "A", + Date = DateTime.Now, + }, + new Unitadfa() + { + Name = "A", + Date = DateTime.Now, + }}).ExecuteCommand(); + var list = db.Queryable().ToList(); + db.DbMaintenance.TruncateTable(); + db.Fastest().OffIdentity().BulkCopy(list); + db.Insertable(new Unitadfa() + { + Name = "A", + Date = DateTime.Now, + }).ExecuteCommand(); + db.DbMaintenance.DropTable(); + + } + } + 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; } + } +}