本文整理汇总了C#中AppFrame.ObjectCriteria.GetOrder方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCriteria.GetOrder方法的具体用法?C# ObjectCriteria.GetOrder怎么用?C# ObjectCriteria.GetOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppFrame.ObjectCriteria
的用法示例。
在下文中一共展示了ObjectCriteria.GetOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAll
/// <summary>
/// Find all EmployeeMoney from database. No pagination.
/// </summary>
/// <param name="criteria"></param>
/// <returns></returns>
public IList FindAll(ObjectCriteria criteria)
{
ISession session = HibernateTemplate.SessionFactory.OpenSession();
try
{
ICriteria hibernateCriteria = session.CreateCriteria(typeof(EmployeeMoney));
if (criteria != null)
{
IDictionary<string, SubObjectCriteria> map = criteria.GetSubCriteria();
if (map.Count > 0)
{
foreach (string key in map.Keys)
{
hibernateCriteria.CreateAlias(key, key);
}
AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());
foreach (string key in map.Keys)
{
SubObjectCriteria subCriteria = null;
map.TryGetValue(key, out subCriteria);
AddCriteriaAndOrder(hibernateCriteria, subCriteria.GetWhere(), subCriteria.GetOrder());
}
}
else
{
AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());
}
}
return hibernateCriteria.List();
}
finally
{
if (session != null)
{
session.Disconnect();
}
}
}
示例2: FindPaging
/// <summary>
/// Find all EmployeeMoney from database. Has pagination.
/// </summary>
/// <param name="criteria"></param>
/// <returns></returns>
public QueryResult FindPaging(ObjectCriteria criteria)
{
QueryResult queryResult = new QueryResult();
if (criteria == null)
{
return null;
}
ISession session = HibernateTemplate.SessionFactory.OpenSession();
try
{
int page = criteria.PageIndex;
int pageSize = criteria.PageSize;
queryResult.Page = page;
int count = Count(criteria);
if (count == 0)
{
return null;
}
queryResult.TotalPage = (((count % pageSize == 0) ? (count / pageSize) : (count / pageSize + 1)));
ICriteria hibernateCriteria = session.CreateCriteria(typeof(EmployeeMoney));
IDictionary<string, SubObjectCriteria> map = criteria.GetSubCriteria();
if (map.Count > 0)
{
foreach (string key in map.Keys)
{
hibernateCriteria.CreateAlias(key, key);
}
AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());
SubObjectCriteria subCriteria = null;
foreach (string key in map.Keys)
{
map.TryGetValue(key, out subCriteria);
AddCriteriaAndOrder(hibernateCriteria, subCriteria.GetWhere(), subCriteria.GetOrder());
}
}
else
{
AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());
}
hibernateCriteria.SetFirstResult((page - 1) * pageSize);
hibernateCriteria.SetMaxResults(pageSize);
IList list = hibernateCriteria.List();
if (list.Count == 0)
{
return null;
}
else
{
queryResult.Result = list;
}
}
finally
{
if (session != null)
{
session.Disconnect();
}
}
return queryResult;
}