From 4520a4c6a614d04dc703c75730e3f2f152696221 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Fri, 19 Jan 2024 14:00:23 +0800
Subject: [PATCH] Add user test case
---
.../SqlSeverTest/UserTestCases/Program.cs | 3 +-
.../UserTestCases/UnitTest/UintSubListadfa.cs | 113 ++++++++++++++++++
2 files changed, 115 insertions(+), 1 deletion(-)
create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UintSubListadfa.cs
diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/Program.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/Program.cs
index cafda32ee..59b649607 100644
--- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/Program.cs
+++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/Program.cs
@@ -13,7 +13,8 @@ namespace OrmTest
///
///
public static void Init()
- {
+ {
+ Unitadfaasdfaaa.Init();
Unitatadffaa1.Init();
UnitOneToManyNsdfafa.Init();
UCustomConditionalFunc.Init();
diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UintSubListadfa.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UintSubListadfa.cs
new file mode 100644
index 000000000..9c11a566d
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UintSubListadfa.cs
@@ -0,0 +1,113 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+
+ public class Unitadfaasdfaaa
+ {
+ public static void Init()
+ {
+ var db = NewUnitTest.Db;
+
+ db.CodeFirst.InitTables();
+ db.DbMaintenance.TruncateTable();
+ db.Insertable(new ClassRoom()
+ {
+ Name = "a"
+ }).ExecuteCommand();
+ db.Insertable(new Teacher()
+ {
+ Name = "b"
+ }).ExecuteCommand();
+ db.Queryable()
+ .Select(s => new TeacherView
+ {
+ Id = s.Id,
+ Name = s.Name,
+ ClassRoom = SqlFunc.Subqueryable()
+ .LeftJoin((c, sc) => c.Id == sc.ClassId)
+ .Where((c, sc) => SqlFunc.Subqueryable().Where(tc => tc.TeacherId == s.Id && tc.ClassRoomId == c.Id).Any())
+ .ToList((c, sc) => new ClassRoomView()
+ {
+ HasStudent = SqlFunc.Subqueryable().Where(st => st.ClassId == c.Id).Any(),
+ }, true)
+ })
+ .ToList();
+ }
+
+ public class Teacher
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+ }
+
+ public class TeacherView
+ {
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+
+ public List ClassRoom { get; set; }
+ }
+
+ public class ClassRoom
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+ }
+
+ public class ClassRoomView
+ {
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+ public bool HasStudent { get; set; }
+ }
+
+ public class TeacherClass
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public int TeacherId { get; set; }
+
+ public int ClassRoomId { get; set; }
+ }
+
+ public class StarClass
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public int ClassId { get; set; }
+ }
+
+ public class Student
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public int ClassId { get; set; }
+ }
+
+ public class StudentClass
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public int StudentId { get; set; }
+
+ public int ClassId { get; set; }
+ }
+ }
+
+}