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
d447beeace
commit
c50a96b624
@ -77,6 +77,7 @@
|
||||
<Compile Include="Models\TestTree.cs" />
|
||||
<Compile Include="Models\Tree.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\Unit01.cs" />
|
||||
<Compile Include="UnitTest\UnitNavInsertadfa1.cs" />
|
||||
<Compile Include="UnitTest\UnitNavInsertIssue.cs" />
|
||||
<Compile Include="UnitTest\UnitInsertNavN.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
Unit01.Init();
|
||||
UnitNavInsertadfa1.Init();
|
||||
UnitNavInsertIssue.Init();
|
||||
UnitInsertNavN.Init();
|
||||
|
51
Src/Asp.Net/SqliteTest/UnitTest/Unit01.cs
Normal file
51
Src/Asp.Net/SqliteTest/UnitTest/Unit01.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class Unit01
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var DB = new SqlSugarScope(new List<ConnectionConfig>()
|
||||
{
|
||||
new ConnectionConfig()
|
||||
{
|
||||
ConfigId = "Main",
|
||||
DbType = DbType.Sqlite,
|
||||
IsAutoCloseConnection = true,
|
||||
ConnectionString =Config.ConnectionString
|
||||
}
|
||||
}, client => { client.Aop.OnLogExecuting = (s, parameters) => Console.WriteLine(s); });
|
||||
|
||||
DB.CodeFirst.InitTables<ULockEntity>();
|
||||
var entity = new ULockEntity() { Id = 1, Name = "a", Ver = 0 };
|
||||
entity=DB.Insertable<ULockEntity>(entity).ExecuteReturnEntity();
|
||||
DB.Updateable(entity)
|
||||
.UpdateColumns(s => new { s.Name, s.Enable })
|
||||
.ExecuteCommandWithOptLock(true);
|
||||
Console.WriteLine("Hello");
|
||||
}
|
||||
|
||||
class ULockEntity
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public bool Enable { get; set; }
|
||||
|
||||
|
||||
[SqlSugar.SugarColumn(IsEnableUpdateVersionValidation = true)] //标识版本字段
|
||||
public long Ver { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string ShowName => $@"{Id}_{Name}";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user