mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add unit test
This commit is contained in:
parent
4bb27026d8
commit
175341cc2f
@ -94,6 +94,7 @@
|
|||||||
<Compile Include="Models\OrderItem.cs" />
|
<Compile Include="Models\OrderItem.cs" />
|
||||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||||
<Compile Include="Models\ViewOrder.cs" />
|
<Compile Include="Models\ViewOrder.cs" />
|
||||||
|
<Compile Include="UnitTest\UFastest.cs" />
|
||||||
<Compile Include="UnitTest\USplit.cs" />
|
<Compile Include="UnitTest\USplit.cs" />
|
||||||
<Compile Include="UnitTest\Models\TB_AdminUser.cs" />
|
<Compile Include="UnitTest\Models\TB_AdminUser.cs" />
|
||||||
<Compile Include="UnitTest\Models\TB_ClientConfig.cs" />
|
<Compile Include="UnitTest\Models\TB_ClientConfig.cs" />
|
||||||
|
@ -31,7 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Fastest2();
|
||||||
SplitTest();
|
SplitTest();
|
||||||
Filter();
|
Filter();
|
||||||
Insert();
|
Insert();
|
||||||
|
63
Src/Asp.Net/SqlServerTest/UnitTest/UFastest.cs
Normal file
63
Src/Asp.Net/SqlServerTest/UnitTest/UFastest.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public partial class NewUnitTest
|
||||||
|
{
|
||||||
|
private static void Fastest2()
|
||||||
|
{
|
||||||
|
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString =Config.ConnectionString,
|
||||||
|
DbType = DbType.PostgreSQL,
|
||||||
|
IsAutoCloseConnection = true
|
||||||
|
});
|
||||||
|
|
||||||
|
db.CodeFirst.InitTables<Test2>();
|
||||||
|
|
||||||
|
//用例代码
|
||||||
|
db.Insertable(new Test2() { p = "1" }).ExecuteCommand();//用例代码
|
||||||
|
|
||||||
|
db.Insertable(new Test2() { p = "2", delPer = 1 }).ExecuteCommand();//用例代码
|
||||||
|
|
||||||
|
var updateList = db.Queryable<Test2>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
db.Fastest<Test2>().BulkCopy(updateList);
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
foreach (var update in updateList)
|
||||||
|
{
|
||||||
|
update.p = index.ToString();
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.Fastest<Test2>().BulkUpdate(updateList);
|
||||||
|
|
||||||
|
Console.WriteLine("用例跑完");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SugarTable("UnitFastest001a")]
|
||||||
|
public class Test2
|
||||||
|
{
|
||||||
|
[SugarColumn(IsNullable = false, IsPrimaryKey = true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = false)]
|
||||||
|
public string p { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? delPer { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime? del_Time { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user