Linq NHibernate 查询子项

Linq NHibernate Query Subitems

我需要获取一些信息,但我是 NHibernate 的新手

我类喜欢:

Person
   Id
   IdAddress
   Address

Address
   Id
   IdCity
   City
   IdNeighborhood
   Neighborhood

和类

City
Neighborhood

我需要所有带有社区 ID 的地址, 这段代码是我查资料的地方,但是这里只得到城市:

using(var session = openSession()){
   var q = session.Query<Person>(a => Id == IdSearch)
           .Fetch(a => a.Address)
           .ThenFetch(a => a.City)
           .ToList();
   session.Clear();
}

我怎样才能获得社区信息?

我找到了答案, 在查询中,需要这样:

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();
}