本文整理汇总了C#中ICriteria.GetCriteriaByAlias方法的典型用法代码示例。如果您正苦于以下问题:C# ICriteria.GetCriteriaByAlias方法的具体用法?C# ICriteria.GetCriteriaByAlias怎么用?C# ICriteria.GetCriteriaByAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICriteria
的用法示例。
在下文中一共展示了ICriteria.GetCriteriaByAlias方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAlias
static void AddAlias(String path, ICriteria criteria)
{
String[] names = path.Split('.');
for (int i = 0; i < names.Length - 1; i++)
{
if (criteria.GetCriteriaByAlias(names[i]) == null)
{
criteria.CreateAlias(names[i], names[i]);
}
}
}
示例2: SetJoinCriteria
private static void SetJoinCriteria(ICriteria cr, Sort sort)
{
if (sort.Column == "e.Firstname")
{
ICriteria cre = cr.GetCriteriaByAlias("e");
if (cre == null)
cr = cr.CreateCriteria("attendance.Employee", "e", JoinType.LeftOuterJoin);
}
}
示例3: SetJoinCriteria
private static void SetJoinCriteria(ICriteria cr, Sort sort)
{
ICriteria crej = cr.GetCriteriaByAlias("ej");
if (sort.Column == "d.Title")
{
ICriteria crd = cr.GetCriteriaByAlias("d");
if (crej != null && crd == null)
cr = crej.CreateCriteria("ej.Designation", "d", JoinType.LeftOuterJoin);
else if (crej == null && crd == null)
{
crej = cr.CreateCriteria("employee.Employeejob", "ej", JoinType.LeftOuterJoin);
cr = crej.CreateCriteria("ej.Designation", "d", JoinType.LeftOuterJoin);
}
}
if (sort.Column == "es.Name")
{
ICriteria cres = cr.GetCriteriaByAlias("es");
if (crej != null && cres == null)
cr = crej.CreateCriteria("employee.Employeejob", "ej", JoinType.LeftOuterJoin);
else if (crej == null && cres == null)
{
crej = cr.CreateCriteria("employee.Employeejob", "ej", JoinType.LeftOuterJoin);
cr = crej.CreateCriteria("ej.Employmentstatus", "es", JoinType.LeftOuterJoin);
}
}
if (sort.Column == "dept.Name")
{
ICriteria crdept = cr.GetCriteriaByAlias("dept");
if (crej != null && crdept == null)
cr = crej.CreateCriteria("ej.Department", "dept", JoinType.LeftOuterJoin);
else if (crej == null && crdept == null)
{
crej = cr.CreateCriteria("employee.Employeejob", "ej", JoinType.LeftOuterJoin);
cr = crej.CreateCriteria("ej.Department", "dept", JoinType.LeftOuterJoin);
}
}
}
示例4: GetFilterCriteria
private static void GetFilterCriteria(ICriteria cr, Dictionary<string, object> filters, Sort sort = null)
{
string employee = Convert.ToString(filters["employee"]);
string staff_id = Convert.ToString(filters["staff_id"]);
int employment_status = (int)filters["employment_status"];
int designation = (int)filters["designation"];
int dept = (int)filters["dept"];
if (!string.IsNullOrEmpty(employee))
{
AbstractCriterion a1 = Restrictions.InsensitiveLike("employee.Firstname", employee, MatchMode.Anywhere);
AbstractCriterion a2 = Restrictions.InsensitiveLike("employee.Middlename", employee, MatchMode.Anywhere);
AbstractCriterion a3 = Restrictions.InsensitiveLike("employee.Lastname", employee, MatchMode.Anywhere);
AbstractCriterion b1 = Restrictions.Or(a1, a2);
AbstractCriterion b2 = Restrictions.Or(b1, a3);
cr.Add(b2);
}
if (!string.IsNullOrEmpty(staff_id))
cr.Add(Restrictions.InsensitiveLike("employee.Staffid", staff_id, MatchMode.Anywhere));
if (employment_status != 0)
{
cr = cr.CreateCriteria("employee.Employeejob", "ej", JoinType.InnerJoin);
cr = cr.CreateCriteria("ej.Employmentstatus", "es", JoinType.InnerJoin);
cr.Add(Restrictions.Eq("es.Id", employment_status));
}
if (designation != 0)
{
ICriteria crej = cr.GetCriteriaByAlias("ej");
if (crej == null)
cr = cr.CreateCriteria("employee.Employeejob", "ej", JoinType.InnerJoin);
else
cr = crej;
cr = cr.CreateCriteria("ej.Designation", "d", JoinType.InnerJoin);
cr.Add(Restrictions.Eq("d.Id", designation));
}
if (dept != 0)
{
ICriteria crej = cr.GetCriteriaByAlias("ej");
if (crej == null)
cr = cr.CreateCriteria("employee.Employeejob", "ej", JoinType.InnerJoin);
else
cr = crej;
cr = cr.CreateCriteria("ej.Department", "dept", JoinType.InnerJoin);
cr.Add(Restrictions.Eq("dept.Id", dept));
}
if (sort != null)
SetJoinCriteria(cr, sort);
}