From a4054e2daa72cd25747fbf3e4dea4c3f44228d9b Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 18 Dec 2022 14:46:42 +0800 Subject: [PATCH] Add unit test --- .../SqlServerTest/UnitTest/UnitSubToList.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UnitSubToList.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UnitSubToList.cs index cebe328bb..5e5ad42cd 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UnitSubToList.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UnitSubToList.cs @@ -62,6 +62,36 @@ namespace OrmTest { throw new Exception("unit error"); } + + var test3 = db.Queryable() + .Select(o => new myDTO5 + { + disCount = SqlFunc.Subqueryable().Where(d => d.Id == o.CustomId).ToList() + }, + true) + .MergeTable() + .ToList(); + + if (test3 .First().disCount.Count==0|| test3.Any(z => z.disCount.Any(y => y.Id != z.CustomId)) || test3.Any(z => z.Id == 0)) + { + throw new Exception("unit error"); + } + + var test4 = db.Queryable() + .LeftJoin((o,i)=>o.Id==i.OrderId) + .LeftJoin((o,i, c) => c.Id == o.CustomId) + .Select((o,i, c) => new myDTO5 + { + OrderName = o.Name, + disCount = SqlFunc.Subqueryable().Where(d => d.Name == c.Name).ToList() + }, + true) + .ToList(); + + if (test4.First().OrderId == 0) + { + throw new Exception("unit error"); + } } private static void TestJoin3(SqlSugarClient db) {