If i have the following classes
public class Order
{
public virtual ISet<OrderItem> OrderItems { get; set; }
}
public class OrderItem
{
public virtual Product Product { get; set; }
}
OrderItem has a one to one relationship with product. What would be the most effectient to get all of this from one sql request.
I’m using nhibernate criteria api. How would i add orderitems and product as jointypes
using (ITransaction transaction = _session.BeginTransaction())
{
try
{
Model.Order order = _session
.CreateCriteria(typeof(Order))
.Add(Restrictions.Eq("Id", id))
.CreateAlias("OrderItems", "orderItems", JoinType.xxxx)
.UniqueResult<Model.Order>();
transaction.Commit();
return order;
}
catch (HibernateException)
{
transaction.Rollback();
_session.Close();
_session.Dispose();
throw;
}
}
1 Answer