From c896146e779a56c429ad2618475fa42142c4c050 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 8 Nov 2023 11:51:50 +0800 Subject: [PATCH] Add user case test --- .../UserTestCases/UnitTest/Main.cs | 1 + .../UserTestCases/UnitTest/UnitSubqueryN.cs | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSubqueryN.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs index ce2220756..98a55121d 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UnitSubqueryN.Init(); Unitadfasfa.Init(); UnitOneToMany1231123.Init(); OneToManyInString.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSubqueryN.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSubqueryN.cs new file mode 100644 index 000000000..4cd5848cf --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitSubqueryN.cs @@ -0,0 +1,70 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace OrmTest +{ + internal class UnitSubqueryN + { + public static void Init() + { + var db = NewUnitTest.Db; + db.CodeFirst.InitTables(); + var data = db.Queryable() + .Where(w => w.shouji_status >= 4 && w.shouji_guid == + SqlFunc.Subqueryable().Where(s => s.amount > 0 + && s.insurance_section_id == + SqlFunc.Subqueryable() + .GroupBy(i => i.insurance_section_id) + .Where(i => i.category_code == "" && i.insurance_section_id == s.insurance_section_id) + .Select(i => i.insurance_section_id) + ).GroupBy(s => s.shouji_guid) + .Select(s => s.shouji_guid) && w.xuqin_code == "") + .ToList(); + } + + [SugarTable("unitshouji")] + public class shouji + + { + public shouji() + + { + } + + public int? shouji_status { get; set; } + + public string shouji_guid { get; set; } + + public string xuqin_code { get; set; } + } + [SugarTable("unitshouji_subnum")] + public class shouji_subnum + { + public shouji_subnum() + + { + } + + public int? amount { get; set; } + + public int? insurance_section_id { get; set; } + + public string shouji_guid { get; set; } + } + [SugarTable("unitinsurance_section_config")] + public class insurance_section_config + { + public insurance_section_config() + + { + } + + + public int insurance_section_id { get; set; } + + public string category_code { get; set; } + } + } +}