diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs index 6786b3a02..b30e6b290 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs @@ -51,7 +51,7 @@ namespace OrmTest db.Insertable(new BookA() { BookId = 3, Names = "c#1", studenId = 2 }).ExecuteCommand(); db.Insertable(new BookA() { BookId = 4, Names = "php", studenId = 3 }).ExecuteCommand(); db.Insertable(new BookA() { BookId = 5, Names = "js", studenId = 4 }).ExecuteCommand(); - + db.Insertable(new BookA() { BookId = 6, Names = "北大jack", studenId = 1 }).ExecuteCommand(); var list2 = db.Queryable() .Includes(x => x.SchoolA, x => x.RoomList)//2个参数就是 then Include @@ -73,6 +73,13 @@ namespace OrmTest .Where(x => x.Books.Any(z => z.BookId == 1)) .Where(x => x.SchoolA.School_Name == "北大") .ToList(); + + + + var list3_1 = db.Queryable() + .Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList()) + .ToList(); + //先用Mapper导航映射查出第二层 var list = db.Queryable().Mapper(x => x.SchoolA, x => x.SchoolId).ToList(); diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs index edc3f274a..8134a3a35 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMany.cs @@ -27,24 +27,46 @@ namespace OrmTest sno="a", username="a01" }).ExecuteCommand(); + db.Insertable(new OperatorInfo() + { + id = "2", + createTime = DateTime.Now, + isDel = 1, + isDisabled = 1, + openid = "", + phone = "", + pwd = "", + realname = "a01", + remark = "a", + sno = "a", + username = "admin" + }).ExecuteCommand(); var id=db.Insertable(new Role() { id=1, createTime=DateTime.Now, name="admin" + }).ExecuteReturnIdentity(); + var id2 = db.Insertable(new Role() + { + id = 2, + createTime = DateTime.Now, + name = "admin" + }).ExecuteReturnIdentity(); db.Insertable(new OptRole() { operId="1", roleId=id }).ExecuteCommand(); + db.Insertable(new OptRole() { id=2, operId = "2", roleId = id2 }).ExecuteCommand(); db.Queryable() .Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1)) .ToList(); var list=db.Queryable() .Includes(x => x.Roles).Where(x => x.Roles.Any()) .ToListAsync().GetAwaiter().GetResult(); - //db.Queryable() - // .Includes(x => x.Roles.Where(z=>z.name==x.realname).ToList()) - // .ToList(); - } + var list2=db.Queryable() + .Includes(x => x.Roles.MappingField(z=>z.name,()=>x.username).ToList()) + .ToList(); + } /// /// 描述: