本文整理汇总了C#中AppFrame.ObjectCriteria.GetWhere方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCriteria.GetWhere方法的具体用法?C# ObjectCriteria.GetWhere怎么用?C# ObjectCriteria.GetWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppFrame.ObjectCriteria
的用法示例。
在下文中一共展示了ObjectCriteria.GetWhere方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Count
/// <summary>
///
/// </summary>
/// <param name="criteria"></param>
/// <returns></returns>
private int Count(ObjectCriteria criteria)
{
ISession session = HibernateTemplate.SessionFactory.OpenSession();
try
{
ICriteria hibernateCriteria = session.CreateCriteria(typeof(EmployeeMoney)).SetProjection(Projections.RowCount()); ;
if (criteria != null)
{
IDictionary<string, SubObjectCriteria> map = criteria.GetSubCriteria();
if (map.Count > 0)
{
foreach (string key in map.Keys)
{
hibernateCriteria.CreateAlias(key, key);
}
foreach (ICriterion criterion in criteria.GetWhere())
{
hibernateCriteria.Add(criterion);
}
SubObjectCriteria subCriteria;
foreach (string key in map.Keys)
{
map.TryGetValue(key, out subCriteria);
foreach (ICriterion criterion in subCriteria.GetWhere())
{
hibernateCriteria.Add(criterion);
}
}
}
else
{
foreach (ICriterion criterion in criteria.GetWhere())
{
hibernateCriteria.Add(criterion);
}
}
}
return ((int)hibernateCriteria.List()[0]);
}
finally
{
if (session != null)
{
session.Disconnect();
}
}
}
示例2: 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();
}
}
}
示例3: 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;
}