当前位置: 首页>>代码示例>>C#>>正文


C# ICriteria.Add方法代码示例

本文整理汇总了C#中ICriteria.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ICriteria.Add方法的具体用法?C# ICriteria.Add怎么用?C# ICriteria.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICriteria的用法示例。


在下文中一共展示了ICriteria.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildCriteria

		protected virtual ICriteria BuildCriteria(ISession session)
		{
			if (cachedCriteria == null)
			{
				if (detachedCriteria != null)
				{
					cachedCriteria = detachedCriteria.GetExecutableCriteria(session);
				}
				else
				{
					cachedCriteria = session.CreateCriteria(targetType);

					if (criterions != null)
					{
						foreach (var queryCriteria in criterions)
						{
							cachedCriteria.Add(queryCriteria);
						}
					}
				}

				if (orders != null)
				{
					foreach (var order in orders)
					{
						cachedCriteria.AddOrder(order);
					}
				}
			}

			return cachedCriteria;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:32,代码来源:ARPaginableCriteria.cs

示例2: AppendStringPropertyCriteriaTo

        private static void AppendStringPropertyCriteriaTo(
			ICriteria criteria, PropertyInfo signatureProperty, object propertyValue)
        {
            criteria.Add(
                propertyValue != null
                    ? Restrictions.InsensitiveLike(signatureProperty.Name, propertyValue.ToString(), MatchMode.Exact)
                    : Restrictions.IsNull(signatureProperty.Name));
        }
开发者ID:ctrlpprint,项目名称:Congregation,代码行数:8,代码来源:EntityDuplicateChecker.cs

示例3: AppendEntityCriteriaTo

        private static void AppendEntityCriteriaTo(
			ICriteria criteria, PropertyInfo signatureProperty, object propertyValue)
        {
            criteria.Add(
                propertyValue != null
                    ? Restrictions.Eq(signatureProperty.Name + ".Id", ((IEntity)propertyValue).Id)
                    : Restrictions.IsNull(signatureProperty.Name + ".Id"));
        }
开发者ID:ctrlpprint,项目名称:Congregation,代码行数:8,代码来源:EntityDuplicateChecker.cs

示例4: AddExpressionToCriteria

 /// <summary>
 /// Adiciona uma Expressão ao ICriteria
 /// </summary>
 /// <param name="type">Tipo da Entidade do ICriteria</param>
 /// <param name="criteria">ICriteria</param>
 /// <param name="propriedade">Nome da Property do Tipo</param>
 /// <param name="expressao">Expressão do ICriteria</param>
 /// <param name="valor">Valor para Comparação</param>
 private void AddExpressionToCriteria(Type type, ICriteria criteria, string propriedade, int expressao, object valor)
 {
     //Converte o valor object no tipo da Property usando Reflection a partir do Type
     object value = Convert.ChangeType(valor, type.GetProperty(propriedade).PropertyType);
     //Adiciona a Expression no Criteria
     switch (expressao)
     {
         case 0:
             criteria.Add(Expression.Eq(propriedade, value));
             break;
         case 1:
             criteria.Add(Expression.Not(Expression.Eq(propriedade, value)));
             break;
         case 2:
             criteria.Add(Expression.Gt(propriedade, value));
             break;
         case 3:
             criteria.Add(Expression.Ge(propriedade, value));
             break;
         case 4:
             criteria.Add(Expression.Lt(propriedade, value));
             break;
         case 5:
             criteria.Add(Expression.Le(propriedade, value));
             break;
         case 6:
             criteria.Add(Expression.Like(propriedade, value));
             break;
     }
 }
开发者ID:vivermais,项目名称:vivermais,代码行数:38,代码来源:RelatorioGenericoDAO.cs

示例5: AddWordRestrictions

 private static void AddWordRestrictions(string query, ICriteria criteria)
 {
     query.Split(' ').ForEach(word => criteria.Add(
         Restrictions.Or(
             Restrictions.InsensitiveLike("Title", word, MatchMode.Anywhere),
             Restrictions.Or(
                 Restrictions.InsensitiveLike("ShortDescription", word, MatchMode.Anywhere),
                 Restrictions.InsensitiveLike("LongDescription", word, MatchMode.Anywhere))
             )));
 }
开发者ID:GiveCampUK,项目名称:CTTSearch,代码行数:10,代码来源:SearchCommand.cs

示例6: AddCriterionToCriteria

		/// <summary>
		/// Adds a collection of ICriterion to an ICriteria.
		/// </summary>
		/// <param name="criteria">The ICriteria that will be modified.</param>
		/// <param name="criterions">The collection of Criterion.</param>
		internal static void AddCriterionToCriteria(ICriteria criteria, ICriterion[] criterions)
		{
			if (criterions != null)
			{
				foreach (ICriterion cond in criterions)
				{
					criteria.Add(cond);
				}
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:15,代码来源:CriteriaHelper.cs

示例7: SetSearchCriteria

 public static ICriteria SetSearchCriteria(object obj, ICriteria c)
 {
     Type t = obj.GetType();
     string strTemp;
     foreach (PropertyInfo p in t.GetProperties())
     {
         if (p.GetValue(obj, null) == null) continue;
         strTemp = p.GetValue(obj, null).ToString();
         if (strTemp != "")
             c.Add(Expression.Eq(p.Name, p.GetValue(obj, null)));
     }
     return c;
 }
开发者ID:BobPalmer,项目名称:Dormouse.Core,代码行数:13,代码来源:Utilities.cs

示例8: ConstructCriteria

        public ICriteria ConstructCriteria(bool matchAllCriteria, ICriteria criteria, params AbstractCriterion[] criterias)
        {
            if (matchAllCriteria)
            {
            var conjunction = Restrictions.Conjunction();

                foreach (var t in criterias.Where(t => t != null))
                {
                    conjunction.Add(t);
                }
                criteria.Add(conjunction);
            }
            else
            {
            var disjunction = Restrictions.Disjunction();

                foreach (var t in criterias.Where(t => t != null))
                {
                    disjunction.Add(t);
                }
                criteria.Add(disjunction);
            }
            return criteria;
        }
开发者ID:Kallivayalil,项目名称:KallivayalilNew,代码行数:24,代码来源:NHibernateCriteriaHelper.cs

示例9: AddCommaDelimitedStringsToExpression

 /// <summary>
 /// Adds the comma delimited strings to the expression factory.
 /// </summary>
 /// <param name="criteria">The criteria.</param>
 /// <param name="expressions">The expressions.</param>
 /// <param name="text">The text.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="clause">The clause.</param>
 private static void AddCommaDelimitedStringsToExpression(ICriteria criteria, IExpressionFactory expressions, String text,
     String propertyName, SearchParameter clause)
 {
     if (!string.IsNullOrEmpty(text))
     {
         IList<IExpression> expression = new List<IExpression>();
         IJunction junction;
         string[] values = text.Split(',');
         foreach (String value in values)
         {
             expression.Add(GetExpression(expressions, clause, propertyName, value));
         }
         junction = expressions.Disjunction();
         foreach (IExpression e in expression)
         {
             junction.Add(e);
         }
         criteria.Add(junction);
     }
     return;
 }
开发者ID:pebre77,项目名称:PrxS2,代码行数:29,代码来源:ManageTargets.ascx.cs

示例10: GetFilterCriteria

 private static void GetFilterCriteria(ICriteria cr, string keyword)
 {
     if (!string.IsNullOrEmpty(keyword))
         cr.Add(Restrictions.InsensitiveLike("dept.Name", keyword, MatchMode.Anywhere));
 }
开发者ID:kenny007,项目名称:Payroll_MVC4,代码行数:5,代码来源:DepartmentHelper.cs

示例11: AddTimePeriodRestrictions

 private static void AddTimePeriodRestrictions(TimePeriod period, ICriteria criteria)
 {
     criteria
         .Add(Restrictions.Eq("Year", period.Year))
         .Add(Restrictions.Eq("YearRange", period.YearRange))
         .Add(Restrictions.Eq("Quarter", period.Quarter))
         .Add(Restrictions.Eq("Month", period.Month));
 }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:8,代码来源:GroupDataReader.cs

示例12: OnSetFilters

    /// <summary>
    /// Called when [set filters] event is fired on the TargetViewDataSource object.
    /// </summary>
    /// <param name="criteria">The criteria.</param>
    /// <param name="expressions">The expressions.</param>
    protected void OnSetFilters(ICriteria criteria, IExpressionFactory expressions)
    {
        ICampaign campaign = GetParentEntity() as ICampaign;
        criteria.Add(expressions.Eq("Campaignid", campaign.Id.ToString()));

        if (!chkContacts.Checked && !chkLeads.Checked)
            criteria.Add(expressions.Eq("TargetType", "NONE"));
        if (chkContacts.Checked && !chkLeads.Checked)
            criteria.Add(expressions.Eq("TargetType", "Contact"));
        if (!chkContacts.Checked && chkLeads.Checked)
            criteria.Add(expressions.Eq("TargetType", "Lead"));
        if (chkPriority.Checked && lbxPriority.SelectedItem != null)
            criteria.Add(expressions.Eq("Priority", lbxPriority.SelectedItem.Text));
        if (chkGroup.Checked && lbxGroups.SelectedItem != null)
            criteria.Add(expressions.Eq("GroupName", lbxGroups.SelectedItem.Text));
        if (chkStatus.Checked && lbxStatus.SelectedItem != null)
            criteria.Add(expressions.Eq("Status", lbxStatus.SelectedItem.Text));
        if (chkStage.Checked && lbxStages.SelectedItem != null)
            criteria.Add(expressions.Eq("Stage", lbxStages.SelectedItem.Text));
        if (chkResponded.Checked)
        {
            criteria.Add(rdgResponded.SelectedIndex == 0
                             ? expressions.IsNotNull("ResponseDate")
                             : expressions.IsNull("ResponseDate"));
        }
    }
开发者ID:ssommerfeldt,项目名称:TAC_EAB,代码行数:31,代码来源:CampaignTargets.ascx.cs

示例13: AddRestriction

 private void AddRestriction(ICriteria criteria, String type, Object value,Boolean exactMatch)
 {
     if (criteria != null && type != null && value != null){
         if (exactMatch){
             criteria.Add(Restrictions.Eq(type, value));
         } else{
             criteria.Add(Restrictions.Like(type, value));
         }
     }
 }
开发者ID:bagheera,项目名称:getin,代码行数:10,代码来源:UserRepository.cs

示例14: GetFilterCriteria

        private void GetFilterCriteria(ICriteria criteria, int find, string keyword)
        {
            string text = string.Format("%{0}%", keyword);

            // Search by make
            if (find == 1)
            {
                ICriterion qmake = Restrictions.Like("Make", text, MatchMode.Anywhere);
                criteria.Add(qmake);
            }

            // Search by model
            else if (find == 2)
            {
                ICriterion qmodel = Restrictions.Like("Model", text, MatchMode.Anywhere);
                criteria.Add(qmodel);
            }

            // Search by year
            else if (find == 3)
            {
                try
                {
                    int year = Convert.ToInt32(keyword);
                    ICriterion qyear = Restrictions.Eq("Year", year);
                    criteria.Add(qyear);
                }

                catch
                {
                }
            }

            // Search by doors
            else if (find == 4)
            {
                try
                {
                    int doors = Convert.ToInt32(keyword);
                    ICriterion qdoors = Restrictions.Eq("Doors", doors);
                    criteria.Add(qdoors);
                }

                catch
                {
                }
            }

            // Search by colour
            else if (find == 5)
            {
                ICriterion qcolour = Restrictions.Like("Colour", text, MatchMode.Anywhere);
                criteria.Add(qcolour);
            }

            // Search by price
            else if (find == 6)
            {
                double price = Convert.ToDouble(keyword);
                ICriterion qprice = Restrictions.Eq("Price", price);
                criteria.Add(qprice);
            }

            // Search all
            else
            {
                bool isNumeric = Utils.IsNumber(keyword);

                if (!isNumeric)
                {
                    ICriterion qmake = Restrictions.Like("Make", text, MatchMode.Anywhere);
                    ICriterion qmodel = Restrictions.Like("Model", text, MatchMode.Anywhere);
                    ICriterion qcolour = Restrictions.Like("Colour", text, MatchMode.Anywhere);

                    AbstractCriterion exp1 = Restrictions.Or(qmake, qmodel);
                    AbstractCriterion exp2 = Restrictions.Or(exp1, qcolour);

                    criteria.Add(exp2);
                }

                else
                {
                    int year = Utils.GetInt(keyword);
                    int doors = Utils.GetInt(keyword);
                    double price = Utils.GetDouble(keyword);

                    ICriterion qyear = Restrictions.Eq("Year", year);
                    ICriterion qdoors = Restrictions.Eq("Doors", doors);
                    ICriterion qprice = Restrictions.Eq("Price", price);

                    ICriterion qmake = Restrictions.Like("Make", text, MatchMode.Anywhere);
                    ICriterion qmodel = Restrictions.Like("Model", text, MatchMode.Anywhere);
                    ICriterion qcolour = Restrictions.Like("Colour", text, MatchMode.Anywhere);

                    AbstractCriterion exp1 = Restrictions.Or(qyear, qdoors);
                    AbstractCriterion exp2 = Restrictions.Or(exp1, qprice);
                    AbstractCriterion exp3 = Restrictions.Or(exp2, qmake);
                    AbstractCriterion exp4 = Restrictions.Or(exp3, qmodel);
                    AbstractCriterion exp5 = Restrictions.Or(exp4, qcolour);

//.........这里部分代码省略.........
开发者ID:wfsiew,项目名称:ASP.NET_MVC3,代码行数:101,代码来源:CarRepository.cs

示例15: Apply

        public override void Apply(ICriteria criteria)
        {
            if (PostId != 0)
            {
                criteria.Add(Expression.Eq("Post.Id", PostId));
            }

            base.Apply(criteria);
        }
开发者ID:dblock,项目名称:dblog,代码行数:9,代码来源:TransitPostLogin.cs


注:本文中的ICriteria.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。