From a3a3dc67d25744053e4e83d383d149a756446f60 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 25 Nov 2024 17:47:27 +0800 Subject: [PATCH] Add user test case --- .../UserTestCases/UnitTest/Main.cs | 1 + .../UserTestCases/UnitTest/Unitdfaydasfa.cs | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfaydasfa.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs index c963b3b85..f887c0caf 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs @@ -33,6 +33,7 @@ namespace OrmTest } public static void Init() { + Unitadfayyadfa.Init(); Unitsdfa1231.Init(); Unitasxdfaaa.Init(); UnitSplitadfaf1.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfaydasfa.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfaydasfa.cs new file mode 100644 index 000000000..2d9985288 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdfaydasfa.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +namespace OrmTest +{ + + internal class Unitadfayyadfa + { + public static void Init() + { + //创建数据库对象 + SqlSugarClient Db = NewUnitTest.Db; + Db.CodeFirst.InitTables(); + + var data = Db.Context.Queryable() + .Select(x => new + { + CategoryName = x.DataType1BInfo.DicInfo.Name + }) + .ToList(); + + var sql = Db.Context.Queryable() + .Select(x => new + { + CategoryName = x.DataType1BInfo.DicInfo.Name + }) + .ToSqlString(); + if (!sql.Contains("WHERE DataType='1'")) + { + throw new Exception("unit error"); + } + } + } + + public class Dic + { + /// + /// + /// + [SugarColumn(ColumnDescription = "type", Length = 50)] + public string? Type { get; set; } + /// + /// + /// + [SugarColumn(ColumnDescription = "code", Length = 50)] + public string? Code { get; set; } + /// + /// + /// + [SugarColumn(ColumnDescription = "Name", Length = 50)] + public string? Name { get; set; } + } + public class View1 + { + public string Name { get; set; } + } + + public enum CategoryEnum + { + Category1 = 1, + Category2 = 2, + Category3 = 3 + } + + [SugarTable("unitAdfafas")] + public class A1 + { + public string Id { get; set; } + /// + /// + /// + [Navigate(NavigateType.OneToOne, nameof(Id), nameof(B1.AId), "DataType='1'")] + public B1 DataType1BInfo { get; set; } + /// + /// + /// + [Navigate(NavigateType.OneToOne, nameof(Id), nameof(B1.AId), "DataType='2'")] + public B1 DataType2BInfo { get; set; } + } + [SugarTable("unitBadfafas")] + public class B1 + { + public string Id { get; set; } + + public string DataType { get; set; } + + public string AId { get; set; } + /// + /// + /// + [Navigate(NavigateType.OneToOne, nameof(Id), nameof(Dic.Code), "Type='Category'")] + public Dic DicInfo { get; set; } + } + +}