nHibernate query looking for the related object's related object

Posted by code-zoop on Stack Overflow See other posts from Stack Overflow or by code-zoop
Published on 2010-04-12T07:59:45Z Indexed on 2010/04/12 8:03 UTC
Read the original article Hit count: 300

Filed under:
|
|
|

I have an nHibernate querie issue that looks quite straight forward, but I can't seem to get my head around it!

I am creating some simple example classes to illustrate my problem:

public class Car {
    public int Id { get; set; }
    public IList<Interior> InteriorParts { get; set; }
}

public class Interior {
    public int Id { get; set; }
    public InteriorProducer Producer { get; set; }
}

public class InteriorProducer {
    public int Id { get; set; }
}

Now to the query: I have the id of the InteriorProducer, but need to get a list of Cars where the interior have been produced by the interior producer.

So in a simple, pseudo SQL, it looks something like this:

select cars
where car.InteriorParts.Producer.Id = Id

I have a really hard time getting my head around this to create an nHibernate query.

Any Ideas?

Thanks

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about c#