mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-02 03:13:58 +08:00
Add demo
This commit is contained in:
@@ -87,6 +87,7 @@
|
|||||||
<Compile Include="UnitTest\UCodeFirst.cs" />
|
<Compile Include="UnitTest\UCodeFirst.cs" />
|
||||||
<Compile Include="UnitTest\UInsert3.cs" />
|
<Compile Include="UnitTest\UInsert3.cs" />
|
||||||
<Compile Include="UnitTest\UJson.cs" />
|
<Compile Include="UnitTest\UJson.cs" />
|
||||||
|
<Compile Include="UnitTest\UnitBulkCopy.cs" />
|
||||||
<Compile Include="UnitTest\Updateable.cs" />
|
<Compile Include="UnitTest\Updateable.cs" />
|
||||||
<Compile Include="UnitTest\UQueryable.cs" />
|
<Compile Include="UnitTest\UQueryable.cs" />
|
||||||
<Compile Include="UnitTest\UQueryableAsync.cs" />
|
<Compile Include="UnitTest\UQueryableAsync.cs" />
|
||||||
|
|||||||
50
Src/Asp.Net/DmTest/UnitTest/UnitBulkCopy.cs
Normal file
50
Src/Asp.Net/DmTest/UnitTest/UnitBulkCopy.cs
Normal file
@@ -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<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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user