From 8d1cf6acc48e615f129e7d609a20101158a53d30 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 12 Apr 2022 13:02:00 +0800 Subject: [PATCH] Update unit test --- .../SqlServerTest/UnitTest/UCustom012.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs index 05d0a7e0d..d16a90a70 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs @@ -96,8 +96,34 @@ namespace OrmTest .Includes(it => it.Parent,it=>it.Parent, it => it.Parent, it => it.Parent) .ToList(); //var json = db.Utilities.SerializeObject(list4); + + db.CodeFirst.InitTables(); + db.DbMaintenance.TruncateTable(); + db.DbMaintenance.TruncateTable(); + + db.Insertable(new UnitA001() { id = 1, name1 = "a", orgid = "1" }).ExecuteCommand(); + db.Insertable(new UnitA002() { id = 1, name2= "a2", orgid = "1" }).ExecuteCommand(); + var list5=db.Queryable().ToList(); + db.ThenMapper(list5, it => + { + it.UnitA002 = db.Queryable().SetContext(x => x.orgid, () => it.id, it).First(); + }); } + public class UnitA001 + { + public int id { get; set; } + public string name1 { get; set; } + public string orgid { get; set; } + [SugarColumn(IsIgnore =true)] + public UnitA002 UnitA002 { get; set; } + } + public class UnitA002 + { + public int id { get; set; } + public string name2{ get; set; } + public string orgid { get; set; } + } public class Tree1 { [SqlSugar.SugarColumn(IsPrimaryKey = true)]