Update Demo

This commit is contained in:
sunkaixuan 2019-05-18 10:11:50 +08:00
parent 878fc4e433
commit d5a0618e26
3 changed files with 22 additions and 0 deletions

View File

@ -140,6 +140,7 @@
<Compile Include="OldTest\UnitTest\Setting\MapColumn.cs" />
<Compile Include="OldTest\UnitTest\Setting\MapTable.cs" />
<Compile Include="OldTest\UnitTest\Update.cs" />
<Compile Include="UnitTest\ObjectsValidate.cs" />
<Compile Include="UnitTest\UJson.cs" />
<Compile Include="UnitTest\Main.cs" />
</ItemGroup>

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class ObjectsValidate
{
public static void Check(object a ,object b,object name)
{
if (a?.ToString() != b?.ToString())
{
new Exception(name+" error");
}
}
}
}

View File

@ -15,7 +15,9 @@ namespace OrmTest
Db.DbMaintenance.TruncateTable<JsonTest>();
Db.Insertable(new JsonTest() { Order = new Order { Id = 1, Name = "order1" } }).ExecuteCommand();
var list = Db.Queryable<JsonTest>().ToList();
ObjectsValidate.Check("order1", list.First().Order.Name, "Json");
Db.Updateable(new JsonTest() { Id = 1, Order = new Order { Id = 2, Name = "order2" } }).ExecuteCommand();
ObjectsValidate.Check("order2", list.First().Order.Name, "Json");
var list2 = Db.Queryable<JsonTest>().ToList();
}
}