nhibernate : how to intialise child list objects

Posted by frosty on Stack Overflow See other posts from Stack Overflow or by frosty
Published on 2010-05-15T18:23:13Z Indexed on 2010/05/15 18:34 UTC
Read the original article Hit count: 210

I have the following method in my repository. This works fine, my orderItems are initialised as intended however orderItems contains another collection called OrderItemAddress. These are not initialised. How would i do this?

public Model.Order Get(int id)
{
    using (ISession session = NHibernateHelper.OpenSession())
    {
        Model.Order order = session
            .CreateCriteria(typeof(Model.Order))
            .Add(Restrictions.Eq("Id", id))
            .UniqueResult<Model.Order>();

        NHibernateUtil.Initialize(order.OrderItems);
        return order;
    }
}

© Stack Overflow or respective owner

Related posts about nhibernate-mapping

Related posts about nhibernate