mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
Update unit test
This commit is contained in:
@@ -36,10 +36,14 @@ namespace OrmTest
|
|||||||
db.Insertable(new StudentA() { StudentId = 3, SchoolId = 2, Name = "清华jack" }).ExecuteCommand();
|
db.Insertable(new StudentA() { StudentId = 3, SchoolId = 2, Name = "清华jack" }).ExecuteCommand();
|
||||||
db.Insertable(new StudentA() { StudentId = 4, SchoolId = 2, Name = "清华tom" }).ExecuteCommand();
|
db.Insertable(new StudentA() { StudentId = 4, SchoolId = 2, Name = "清华tom" }).ExecuteCommand();
|
||||||
|
|
||||||
|
//先用Mapper导航映射查出第二层
|
||||||
var list = db.Queryable<StudentA>().Mapper(x => x.SchoolA, x => x.SchoolId).ToList();
|
var list = db.Queryable<StudentA>().Mapper(x => x.SchoolA, x => x.SchoolId).ToList();
|
||||||
|
|
||||||
|
//参数1 :将第二层对象合并成一个集合 参数2:委托
|
||||||
|
//说明:如果2级对象是集合用SelectMany
|
||||||
db.ThenMapper(list.Select(it => it.SchoolA), sch =>
|
db.ThenMapper(list.Select(it => it.SchoolA), sch =>
|
||||||
{
|
{
|
||||||
|
//参数1: room表关联字段 参数2: school表关联字段, 参数3: school当前记录
|
||||||
sch.RoomList = db.Queryable<RoomA>().SetContext(room => room.SchoolId, () => sch.SchoolId, sch).ToList();
|
sch.RoomList = db.Queryable<RoomA>().SetContext(room => room.SchoolId, () => sch.SchoolId, sch).ToList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user