我需要獲取一些信息,但我是 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貢獻(xiàn)1831條經(jīng)驗 獲得超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 關(guān)注
- 233 瀏覽
添加回答
舉報
0/150
提交
取消