English 中文(简体)
Fetching with Join QueryOver: Get grandgrandchildren, knowledge original
原标题:Fetching with JoinQueryOver: Get greatgrandchildren, know father

Object Structure: A house has many rooms. A room has many tables. A table has many vases (on it).

House > 会议室;桌椅;瓦西。

我愿利用Join QueryOver在某个房屋中选择所有有红色的血管表。

我认为这是:

var v = session.QueryOver<House>()
    .Where(x => x.ID == HouseID)
        .JoinQueryOver<Room>(x => x.Rooms)
            .JoinQueryOver<Table>(x => x.Tables)
                .JoinQueryOver<Vase>(x => x.Vases)
                    .Where(x => x.Color == "Red")
    .SingleOrDefault<House>();

这是我尝试的一种做法(许多失败者)。 我并不真的想要下议院和会议厅。

最后,我看一看一张桌子清单(某个房屋),收集瓦西(红色)的表格。

得到帮助!

<><>Edit>/strong>

与此类似:

var v = session.QueryOver<Table>()
        .Where(x => x.Room.House.ID == HouseID) // this Where won t work.
            .JoinQueryOver<Vase>(x => x.Vases)
                .Where(x => x.Color == "Red")
        .List().ToList();
最佳回答
var v = session.QueryOver<Table>()
    .JoinAlias(x => x.Room, () => room)
    .Where(() => room.House.ID == HouseID)
    .JoinQueryOver<Vase>(x => x.Vases)
        .Where(x => x.Color == "Red")
    .List();
问题回答

暂无回答




相关问题
nHibernate one-to-many inserts but doesnt update

Instead of getting into code, I have a simple question. Default behavior for a simple one-to-many is that it inserts the child record then updates the foreign key column with the parent key. Has ...

How Do I copy an existing nhibernate object as a new object?

I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new? I am thinking I might create a session interceptor to ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

NHibernate Search in a List using ICriteria

I have my class X : public class ClassX { public virtual IList<ClassY> ListY { get; set; } ... } My ClassX mapping (using Fluent) ... HasMany<ClassX>(x => x.ListY ) ....

热门标签