mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update unit test
This commit is contained in:
parent
8a72f18798
commit
dc4d08a731
@ -99,6 +99,7 @@
|
|||||||
<Compile Include="Models\Tree.cs" />
|
<Compile Include="Models\Tree.cs" />
|
||||||
<Compile Include="Models\ViewOrder.cs" />
|
<Compile Include="Models\ViewOrder.cs" />
|
||||||
<Compile Include="Config.cs" />
|
<Compile Include="Config.cs" />
|
||||||
|
<Compile Include="UnitTest\UCustom08.cs" />
|
||||||
<Compile Include="UnitTest\UAopTest.cs" />
|
<Compile Include="UnitTest\UAopTest.cs" />
|
||||||
<Compile Include="UnitTest\UCustom01.cs" />
|
<Compile Include="UnitTest\UCustom01.cs" />
|
||||||
<Compile Include="UnitTest\UCustom011.cs" />
|
<Compile Include="UnitTest\UCustom011.cs" />
|
||||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
UCustom08.Init();
|
||||||
UCustom012.Init();
|
UCustom012.Init();
|
||||||
UCustom014.Init();
|
UCustom014.Init();
|
||||||
UCustom015.Init();
|
UCustom015.Init();
|
||||||
|
80
Src/Asp.Net/PgSqlTest/UnitTest/UCustom08.cs
Normal file
80
Src/Asp.Net/PgSqlTest/UnitTest/UCustom08.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SqlSugar;
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class UCustom08
|
||||||
|
{
|
||||||
|
[SugarTable("Unit00UpdateTest")]
|
||||||
|
|
||||||
|
public class UpdateTest
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "主键", IsPrimaryKey = true)]
|
||||||
|
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "名称", ColumnDataType = "varchar(100)")]
|
||||||
|
|
||||||
|
public string TN { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = true, ColumnDescription = "测试")]
|
||||||
|
|
||||||
|
public long? T1 { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
|
||||||
|
db.Aop.OnError = (exp) =>//SQL报错
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
string sql = exp.Sql;
|
||||||
|
|
||||||
|
//exp.sql 这样可以拿到错误SQL
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
db.DbMaintenance.CreateDatabase();
|
||||||
|
|
||||||
|
db.CodeFirst.InitTables(typeof(UpdateTest));
|
||||||
|
|
||||||
|
var id = Guid.NewGuid();
|
||||||
|
|
||||||
|
db.Insertable(new UpdateTest { Id = id, TN = "asdasd" }).ExecuteCommand();
|
||||||
|
|
||||||
|
var data = db.Queryable<UpdateTest>().Where(x => x.Id == id).First();
|
||||||
|
|
||||||
|
db.Updateable<UpdateTest>()
|
||||||
|
.SetColumns(x => new UpdateTest { T1 = (int)data.T1 }).Where(x => x.Id == id).ExecuteCommand();
|
||||||
|
|
||||||
|
db.Updateable<UpdateTest>()
|
||||||
|
.SetColumns(x => new UpdateTest { T1 = data.T1 }).Where(x => x.Id == id).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
db.Updateable<UpdateTest>()
|
||||||
|
.SetColumns(x => new UpdateTest { T1 = 1 }).Where(x => x.Id == id).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
Console.ReadKey();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user