我正在尝试选择一个实体并获取相关列表:
Session.QueryOver<UserRole>()
.Fetch(x => x.UsersInRole).Eager
.List();
这导致很多数据库命中。第一个是这样的:
SELECT ... FROM UserRoles
left outer join UsersInRoles on ...
还有数百个单独的查询,如下所示:
SELECT ... FROM UsersInRoles
left outer join UserRoles on ...
WHERE UserRoles.UserId=?
映射如下:
public class UserRoleMap : ClassMap<UserRole>
{
public UserRoleMap()
{
Id(x => x.Id);
Map(x => x.RoleName);
HasManyToMany(x => x.UsersInRole)
.Inverse()
.LazyLoad()
.Table("UsersInRoles");
}
}
RISEBY
回首忆惘然
相关分类