我需要获取一些信息,但我是 NHibernate 的新手我有这样的课程:Person Id IdAddress AddressAddress Id IdCity City IdNeighborhood Neighborhood和班级CityNeighborhood我需要所有带有邻居 ID 的地址,这段代码是我搜索信息的地方,但这里只能获取城市:using(var session = openSession()){ var q = session.Query<Person>(a => Id == IdSearch) .Fetch(a => a.Address) .ThenFetch(a => a.City) .ToList(); session.Clear();}我怎样才能获得邻里信息?
1 回答
天涯尽头无女友
TA贡献1831条经验 获得超9个赞
我找到了答案,在查询中,需要这样:
using(var session = openSession()){
var q = session.Query<Person>(a => Id == IdSearch)
.Fetch(a => a.Address)
.ThenFetch(a => a.City)
.Fetch(a => a.Address)//search address again to have access to neighboorhoor
.ThenFetch(a => a.Neighborhood)
.ToList();
session.Clear();
}
- 1 回答
- 0 关注
- 210 浏览
添加回答
举报
0/150
提交
取消