本文整理汇总了C#中ICriteria.CreateCriteria方法的典型用法代码示例。如果您正苦于以下问题:C# ICriteria.CreateCriteria方法的具体用法?C# ICriteria.CreateCriteria怎么用?C# ICriteria.CreateCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICriteria
的用法示例。
在下文中一共展示了ICriteria.CreateCriteria方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCriteria
public ICriteria AddCriteria(ICriteria criteria)
{
Debug.Assert(_objectId >= 0);
var rest = Restrictions.Eq("Id", _objectId);
var subcriteria = criteria.CreateCriteria(_propertyName);
subcriteria.Add(rest);
return criteria;
}
示例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: GetFilterCriteria
private static void GetFilterCriteria(ICriteria cr, Dictionary<string, object> filters, Sort sort = null)
{
string employee = Convert.ToString(filters["employee"]);
DateTime work_date = (DateTime)filters["work_date"];
if (!string.IsNullOrEmpty(employee))
{
cr = cr.CreateCriteria("attendance.Employee", "e", JoinType.InnerJoin);
AbstractCriterion a1 = Restrictions.InsensitiveLike("e.Firstname", employee, MatchMode.Anywhere);
AbstractCriterion a2 = Restrictions.InsensitiveLike("e.Middlename", employee, MatchMode.Anywhere);
AbstractCriterion a3 = Restrictions.InsensitiveLike("e.Lastname", employee, MatchMode.Anywhere);
AbstractCriterion b1 = Restrictions.Or(a1, a2);
AbstractCriterion b2 = Restrictions.Or(b1, a3);
cr.Add(b2);
}
if (work_date != default(DateTime))
cr.Add(Restrictions.Eq("attendance.Workdate", work_date));
if (sort != null)
SetJoinCriteria(cr, sort);
}
示例4: AddExpressionsCriteria
/// <summary>
/// Adds the expressions criteria.
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <param name="expressions">The expressions.</param>
/// <returns></returns>
private void AddExpressionsCriteria(ICriteria criteria, IExpressionFactory expressions)
{
if (criteria != null)
{
SearchParameter clause;
Boolean isLeads = (rdgIncludeType.SelectedIndex == 0);
Boolean isPrimaryContact = (rdgIncludeType.SelectedIndex == 1);
Boolean isIndividual = (rdgIncludeType.SelectedIndex == 3);
criteria.Add(expressions.Eq("address.IsPrimary", true));
if (isPrimaryContact)
{
criteria.Add(expressions.Eq("a1.IsPrimary", true));
}
if (chkCompany.Checked)
{
clause = (SearchParameter)lbxCompany.SelectedIndex;
if (isLeads)
criteria.Add(GetExpression(expressions, clause, "a1.Company", txtCompany.Text));
else
criteria.Add(GetExpression(expressions, clause, "account.AccountName", txtCompany.Text));
}
if (chkIndustry.Checked)
{
clause = (SearchParameter)lbxIndustry.SelectedIndex;
if (isLeads)
criteria.Add(GetExpression(expressions, clause, "a1.Industry", pklIndustry.PickListValue));
else
criteria.Add(GetExpression(expressions, clause, "account.Industry", pklIndustry.PickListValue));
}
if (chkSIC.Checked)
{
clause = (SearchParameter)lbxSIC.SelectedIndex;
if (isLeads)
criteria.Add(GetExpression(expressions, clause, "a1.SICCode", txtSIC.Text));
else
criteria.Add(GetExpression(expressions, clause, "account.SicCode", txtSIC.Text));
}
if (chkTitle.Checked)
{
clause = (SearchParameter)lbxTitle.SelectedIndex;
criteria.Add(GetExpression(expressions, clause, "a1.Title", pklTitle.PickListValue));
}
if (chkProducts.Checked && !isLeads)
{
criteria.CreateCriteria("account.AccountProducts", "product");
clause = (SearchParameter)lbxProducts.SelectedIndex;
criteria.Add(GetExpression(expressions, clause, "product.ProductName", lueProducts.Text));
}
if (chkStatus.Checked)
{
clause = (SearchParameter)lbxStatus.SelectedIndex;
if (isLeads || isIndividual)
criteria.Add(GetExpression(expressions, clause, "a1.Status", pklStatus.PickListValue));
else
criteria.Add(GetExpression(expressions, clause, "account.Status", pklStatus.PickListValue));
}
if (!chkSolicit.Checked)
criteria.Add(expressions.Or(expressions.Eq("a1.DoNotSolicit", false), expressions.IsNull("a1.DoNotSolicit")));
if (!chkEmail.Checked)
criteria.Add(expressions.Or(expressions.Eq("a1.DoNotEmail", false), expressions.IsNull("a1.DoNotEmail")));
if (!chkCall.Checked)
criteria.Add(expressions.Or(expressions.Eq("a1.DoNotPhone", false), expressions.IsNull("a1.DoNotPhone")));
if (!chkMail.Checked)
criteria.Add(expressions.Or(expressions.Eq("a1.DoNotMail", false), expressions.IsNull("a1.DoNotMail")));
if (!chkFax.Checked)
{
if (isLeads)
criteria.Add(expressions.Or(expressions.Eq("a1.DoNotFAX", false), expressions.IsNull("a1.DoNotFAX")));
else
criteria.Add(expressions.Or(expressions.Eq("a1.DoNotFax", false), expressions.IsNull("a1.DoNotFax")));
}
if (chkCity.Checked)
{
clause = (SearchParameter)lbxCity.SelectedIndex;
AddCommaDelimitedStringsToExpression(criteria, expressions, txtCity.Text, "address.City", clause);
}
if (chkState.Checked)
{
clause = (SearchParameter)lbxState.SelectedIndex;
AddCommaDelimitedStringsToExpression(criteria, expressions, txtState.Text, "address.State", clause);
}
if (chkZip.Checked)
{
clause = (SearchParameter)lbxZip.SelectedIndex;
AddCommaDelimitedStringsToExpression(criteria, expressions, txtZip.Text, "address.PostalCode", clause);
}
if (chkLeadSource.Checked)
{
switch (rdgIncludeType.SelectedIndex)
{
case 0:
criteria.CreateCriteria("a1.LeadSource", "leadsource");
break;
//.........这里部分代码省略.........
示例5: GetFilterCriteria
private static void GetFilterCriteria(ICriteria cr, Dictionary<string, object> filters)
{
string employee = Convert.ToString(filters["employee"]);
string username = Convert.ToString(filters["username"]);
int role = (int)filters["role"];
int status = (int)filters["status"];
bool statusVal = status == 1 ? true : false;
if (!string.IsNullOrEmpty(username))
cr.Add(Restrictions.InsensitiveLike("user.Username", username, MatchMode.Anywhere));
if (role != 0)
cr.Add(Restrictions.Eq("user.Role", role));
if (status != 0)
cr.Add(Restrictions.Eq("user.Status", statusVal));
if (!string.IsNullOrEmpty(employee))
{
cr = cr.CreateCriteria("user.Employee", "e", JoinType.InnerJoin);
AbstractCriterion a1 = Restrictions.InsensitiveLike("e.Firstname", employee, MatchMode.Anywhere);
AbstractCriterion a2 = Restrictions.InsensitiveLike("e.Middlename", employee, MatchMode.Anywhere);
AbstractCriterion a3 = Restrictions.InsensitiveLike("e.Lastname", employee, MatchMode.Anywhere);
AbstractCriterion b1 = Restrictions.Or(a1, a2);
AbstractCriterion b2 = Restrictions.Or(b1, a3);
cr.Add(b2);
}
}
示例6: CreateSubcriteria
public ICriteria CreateSubcriteria(ICriteria parent, IEnumerable<ICriteriaEvent> criteriaEvents)
{
// call the right overload to actually create the Criteria
ICriteria crit;
switch(methodSig)
{
case MethodSig.Association:
crit = parent.CreateCriteria(association);
break;
case MethodSig.AssociationAndJoinType:
crit = parent.CreateCriteria(association, joinType);
break;
case MethodSig.AssociationAndAlias:
crit = parent.CreateCriteria(association, alias);
break;
case MethodSig.AssociationAndAliasAndJoinType:
crit = parent.CreateCriteria(association, alias, joinType);
break;
default:
throw new ShardedSessionException("Unknown constructor type for subcriteria creation: " + methodSig);
}
// apply the events
foreach(ICriteriaEvent criteriaEvent in criteriaEvents)
{
criteriaEvent.OnEvent(crit);
}
return crit;
}
示例7: 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);
}
}
}
示例8: 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);
}