我试图检索例如最后 5 个订单,但我得到了最后 5 个单位!
Model.Order orderAlias = null;
Model.Unit unitsAlias = null;
Model.Employee employeeAlias = null;
IList<Model.Unit> itemList = null;
using (m_hibernateSession.BeginTransaction())
{
var query = m_hibernateSession.QueryOver<Model.Unit>(() => unitsAlias)
.JoinAlias(() => unitsAlias.OrderRef, () => orderAlias, JoinType.InnerJoin)
.JoinAlias(() => unitsAlias.EmployeeRef, () => employeeAlias, JoinType.InnerJoin);
// add additional filters if set
if (propertiesNames.Keys.Contains("Employee")) query.Where(Restrictions.On(() => employeeAlias.Name).IsLike( "%" + (string)propertiesNames["Employee"] + "%"));
if (propertiesNames.Keys.Contains("Division")) query.Where(() => unitsAlias.Division == (string)propertiesNames["Division"]);
query.Where(() => orderAlias.PONumber != 0).OrderBy(() => orderAlias.PONumber).Desc.Take(5);
itemList = query.List<Model.Unit>();
}
要获得最后 5 个订单的单位,需要进行哪些更改?
谢谢