mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
Update unit test
This commit is contained in:
parent
d4d6ba4ef3
commit
1b1487a120
@ -35,8 +35,8 @@ namespace OrmTest
|
||||
|
||||
|
||||
var list = db.Queryable<Student_001>()
|
||||
.Includes(x => x.school_001, x => x.rooms)
|
||||
.Where(x=>x.school_001.rooms.Any(z=>z.rooms.Any())).ToList();
|
||||
.Includes(x => x.school_001, x => x.rooms, x => x.desk)
|
||||
.Where(x => x.school_001.rooms.Any(z => z.desk.Any())).ToList();
|
||||
|
||||
if (list.Count() != 2)
|
||||
{
|
||||
@ -47,7 +47,7 @@ namespace OrmTest
|
||||
.Includes(x => x.school_001, x => x.rooms)
|
||||
.Where(x => x.school_001.rooms.Any(z =>
|
||||
z.roomName == "北大01室" &&
|
||||
z.rooms.Any())).ToList();
|
||||
z.desk.Any())).ToList();
|
||||
|
||||
|
||||
if (list2.Count() != 1)
|
||||
@ -59,7 +59,7 @@ namespace OrmTest
|
||||
.Includes(x => x.school_001, x => x.rooms)
|
||||
.Where(x => x.school_001.rooms.Any(z =>
|
||||
z.roomName == "青华03室" &&
|
||||
z.rooms.Any(c=>c.deskName== "青华03室_01"))).ToList();
|
||||
z.desk.Any(c => c.deskName == "青华03室_01"))).ToList();
|
||||
|
||||
if (list3.Count != 1)
|
||||
{
|
||||
@ -69,14 +69,28 @@ namespace OrmTest
|
||||
var list4 = db.Queryable<Student_001>()
|
||||
.Where(x => x.school_001.rooms.Any(z =>
|
||||
z.roomName == "青华03室" &&
|
||||
z.rooms.Any(c => c.deskName == "青华04室_01"))).ToList();
|
||||
z.desk.Any(c => c.deskName == "青华04室_01"))).ToList();
|
||||
|
||||
|
||||
if (list4.Count != 0)
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
db.DbMaintenance.TruncateTable<Student_001, School_001, Room_001, Desk_001>();
|
||||
db.InsertNav(list.First())
|
||||
.ThenInclude(x => x.school_001)
|
||||
.ThenInclude(x => x.rooms)
|
||||
.ThenInclude(x => x.desk);
|
||||
db.InsertNav(list.Last())
|
||||
.ThenInclude(x => x.school_001)
|
||||
.ThenInclude(x => x.rooms)
|
||||
.ThenInclude(x => x.desk);
|
||||
|
||||
if (db.Queryable<Desk_001>().Count() != 4 || db.Queryable<Room_001>().Count() != 4
|
||||
|| db.Queryable<School_001>().Count() != 2 || db.Queryable<Student_001>().Count() != 2)
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
}
|
||||
|
||||
public class Student_001
|
||||
@ -107,7 +121,7 @@ namespace OrmTest
|
||||
public int schoolId { get; set; }
|
||||
public string roomName { get; set; }
|
||||
[SqlSugar.Navigate(SqlSugar.NavigateType.OneToMany, nameof(Desk_001.roomId))]
|
||||
public List<Desk_001> rooms { get; set; }
|
||||
public List<Desk_001> desk { get; set; }
|
||||
}
|
||||
|
||||
public class Desk_001
|
||||
|
Loading…
Reference in New Issue
Block a user