diff --git a/Src/Asp.NetCore2/SqliteTest/UserTestCases/Program.cs b/Src/Asp.NetCore2/SqliteTest/UserTestCases/Program.cs index c54b7fb20..5a67edeb1 100644 --- a/Src/Asp.NetCore2/SqliteTest/UserTestCases/Program.cs +++ b/Src/Asp.NetCore2/SqliteTest/UserTestCases/Program.cs @@ -7,6 +7,7 @@ namespace SqliteTest.UnitTest { public static void Init() { + Unitadfadsyyy.Init(); //Demo Demo0_SqlSugarClient.Init(); Demo1_Queryable.Init(); diff --git a/Src/Asp.NetCore2/SqliteTest/UserTestCases/Unitadfadf1.cs b/Src/Asp.NetCore2/SqliteTest/UserTestCases/Unitadfadf1.cs new file mode 100644 index 000000000..f441d4b59 --- /dev/null +++ b/Src/Asp.NetCore2/SqliteTest/UserTestCases/Unitadfadf1.cs @@ -0,0 +1,73 @@ +using SqlSugar; +using System.Collections.Generic; +using System; + +namespace OrmTest +{ + public class Unitadfadsyyy + { + public static void Init() + { + var db = new SqlSugarScope(new List() + { + new() + { + ConfigId = "Main", + ConnectionString = $@"DataSource={Environment.CurrentDirectory}\test12.db", + DbType = DbType.Sqlite, + IsAutoCloseConnection = true + } + }, client => { client.Aop.OnLogExecuting = (s, parameters) => Console.WriteLine(s); }); + + db.CodeFirst.InitTables(); + + var list=db.Queryable() + .IncludeLeftJoin(s => s.StartStudent) + .Where(s => s.Name.StartsWith("张")) + .Select(s => new StudentDto() + { + StarLevel = s.StartStudent.StarLevel, + },true) + .ToList(); + } + + public class Student1231231 + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + public string Name { get; set; } + + public string Age { get; set; } + + public string Phone { get; set; } + public string Address { get; set; } + + [Navigate(NavigateType.OneToOne, nameof(Id), nameof(StarStudent12313131.StudentId))] + public StarStudent12313131 StartStudent { get; set; } + } + + public class StarStudent12313131 + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + public int StudentId { get; set; } + + public int StarLevel { get; set; } + } + + public class StudentDto + { + public int Id { get; set; } + + public string Name { get; set; } + public string Age { get; set; } + + public string Phone { get; set; } + public string Address { get; set; } + + public int StarLevel { get; set; } + } + } +} \ No newline at end of file