Below is the method in our DAO object to return the list.
FutureResidual is the child object, RegistrationYear/Month is how we decide which property the data should be loaded in
Code:
public IList<FutureResidual> GetUsedFutureResiduals(int dataset, Derivative derivative)
{
return CreateCriteria("FutureResidual")
.Add(Expression.Eq("DerivativeId", derivative.Id))
.Add(Expression.Eq("DataProviderId", dataset))
.Add(Expression.Ge("RegistrationYear",0))
.Add(Expression.Ge("RegistrationMonth",0))
.AddOrder(Order.Desc("RegistrationYear"))
.AddOrder(Order.Desc("RegistrationMonth"))
.AddOrder(Order.Asc("FinanceTerm"))
.AddOrder(Order.Asc("MileageAtEndOfAgreement"))
.List<FutureResidual>();
}
We then put this list into the parent object