diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj index 9605a4a27..8954e08d2 100644 --- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj +++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj @@ -95,6 +95,7 @@ + diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs index 6505094ed..065518203 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs @@ -32,6 +32,7 @@ namespace OrmTest public static void Init() { UByteArray.Init(); + UCustom021.Inti(); UCustom020.Init(); UCustom019.Init(); UnitManyToMany.Init(); diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom021.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom021.cs new file mode 100644 index 000000000..d3c5c6c56 --- /dev/null +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom021.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +namespace OrmTest +{ + public class UCustom021 + { + public static void Inti() { + var db = NewUnitTest.Db; + db.CodeFirst.SetStringDefaultLength(20).InitTables(); + db.CodeFirst.SetStringDefaultLength(20).InitTables(); + + var id = db.Insertable(new UnitStudent111() { Name = "小a" }).ExecuteReturnIdentity(); + db.Insertable(new UnitExam + { + StudentId = id, + Number = 1, + Time = DateTime.Now + }).ExecuteCommand(); + + var result2 = db.Queryable() + .Includes(e => e.Exams.Where(s => s.Id >e.Id).ToList()).ToList(); + + + + } + } + + public class UnitStudent111 + { + [SugarColumn(IsIdentity = true, IsPrimaryKey = true)] + public int Id { get; set; } + public string Name { get; set; } + [Navigate(NavigateType.OneToMany, nameof(UnitExam.StudentId))]//BookA表中的studenId + public List Exams { get; set; } + + } + public class UnitExam + { + [SugarColumn(IsIdentity = true, IsPrimaryKey = true)] + public int Id { get; set; } + public int StudentId { get; set; } + public int Number { get; set; } + public DateTime Time { get; set; } + + } +}