• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ICriteria类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICriteria的典型用法代码示例。如果您正苦于以下问题:C# ICriteria类的具体用法?C# ICriteria怎么用?C# ICriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: ToSqlString

        public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
        {
            var sqlBuilder = new SqlStringBuilder();
            SqlString[] columnNames = null;

            if (_propertyName != "*")
            {
                columnNames = CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria, enabledFilters);

                if (columnNames.Length != 1)
                {
                    throw new HibernateException("Contains may only be used with single-column properties");
                }
            } else
            {
                columnNames = new SqlString[]
                                  {
                                      new SqlString("*")
                                  };
            }

            sqlBuilder.Add("contains(")
              .Add(columnNames[0])
              .Add(",");

            sqlBuilder.Add(criteriaQuery.NewQueryParameter(GetParameterTypedValue(criteria, criteriaQuery)).Single());
            sqlBuilder.Add(")");

            return sqlBuilder.ToSqlString();
        }
开发者ID:theriddlebrothers,项目名称:Honeypot,代码行数:30,代码来源:ContainsExpression.cs


示例2: GetTypedValues

		public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			return new TypedValue[]
				{
					criteriaQuery.GetTypedValue(criteria, _propertyName, _value.ToString().ToLower())
				};
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:7,代码来源:InsensitiveLikeExpression.cs


示例3: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			string entityName = criteriaQuery.GetEntityName(criteria, propertyName);
			string actualPropertyName = criteriaQuery.GetPropertyName(propertyName);
			string sqlAlias = criteriaQuery.GetSQLAlias(criteria, propertyName);

			ISessionFactoryImplementor factory = criteriaQuery.Factory;
			IQueryableCollection collectionPersister = GetQueryableCollection(entityName, actualPropertyName, factory);

			string[] collectionKeys = collectionPersister.KeyColumnNames;
			string[] ownerKeys = ((ILoadable)factory.GetEntityPersister(entityName)).IdentifierColumnNames;

			StringBuilder innerSelect = new StringBuilder();
			innerSelect.Append("(select 1 from ")
				.Append(collectionPersister.TableName)
				.Append(" where ")
				.Append(
				new ConditionalFragment().SetTableAlias(sqlAlias).SetCondition(ownerKeys, collectionKeys).ToSqlStringFragment());
			if (collectionPersister.HasWhere)
			{
				innerSelect.Append(" and (")
					.Append(collectionPersister.GetSQLWhereString(collectionPersister.TableName))
					.Append(") ");
			}

			innerSelect.Append(")");

			return new SqlString(new string[] {ExcludeEmpty ? "exists" : "not exists", innerSelect.ToString()});
		}
开发者ID:jaundice,项目名称:nhibernate-core,代码行数:29,代码来源:AbstractEmptinessExpression.cs


示例4: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery,
											  IDictionary<string, IFilter> enabledFilters)
		{
			SqlString[] columnNames =
				CriterionUtil.GetColumnNames(_lhsPropertyName, _lhsProjection, criteriaQuery, criteria, enabledFilters);
			SqlString[] otherColumnNames =
				CriterionUtil.GetColumnNames(_rhsPropertyName, _rhsProjection, criteriaQuery, criteria, enabledFilters);

			SqlStringBuilder sb = new SqlStringBuilder();
			if (columnNames.Length > 1)
			{
				sb.Add(StringHelper.OpenParen);
			}
			bool first = true;
			foreach (SqlString sqlString in StringHelper.Add(columnNames, Op, otherColumnNames))
			{
				if (first == false)
				{
					sb.Add(" and ");
				}
				first = false;
				sb.Add(sqlString);
			}

			if (columnNames.Length > 1)
			{
				sb.Add(StringHelper.ClosedParen);
			}

			return sb.ToSqlString();
		}
开发者ID:pallmall,项目名称:WCell,代码行数:31,代码来源:PropertyExpression.cs


示例5: GetProjectionArgument

 private static SqlString GetProjectionArgument(ICriteriaQuery criteriaQuery, ICriteria criteria,
                                                IProjection projection, int loc,
                                                IDictionary<string, IFilter> enabledFilters)
 {
     SqlString sql = projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters);
     return StringHelper.RemoveAsAliasesFromSql(sql);
 }
开发者ID:justintoth,项目名称:NHibernate.OData,代码行数:7,代码来源:OperatorProjection.cs


示例6: GetTypes

		public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			IType[] trueTypes = whenTrue.GetTypes(criteria, criteriaQuery);
			IType[] falseTypes = whenFalse.GetTypes(criteria, criteriaQuery);

			bool areEqual = trueTypes.Length == falseTypes.Length;
			if (trueTypes.Length == falseTypes.Length)
			{
				for (int i = 0; i < trueTypes.Length; i++)
				{
					if(trueTypes[i] != falseTypes[i])
					{
						areEqual = false;
						break;
					}
				}
			}
			if(areEqual == false)
			{
				string msg = "Both true and false projections must return the same types."+ Environment.NewLine +
				             "But True projection returns: ["+StringHelper.Join(", ", trueTypes) +"] "+ Environment.NewLine+
				             "And False projection returns: ["+StringHelper.Join(", ", falseTypes)+ "]";

				throw new HibernateException(msg);
			}

			return trueTypes;
		}
开发者ID:pallmall,项目名称:WCell,代码行数:28,代码来源:ConditionalProjection.cs


示例7: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			//TODO: add default capacity
			SqlStringBuilder sqlBuilder = new SqlStringBuilder();

			SqlString[] columnNames =
				CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria, enabledFilters);

			bool opNeeded = false;

			for (int i = 0; i < columnNames.Length; i++)
			{
				if (opNeeded)
				{
					sqlBuilder.Add(" or ");
				}
				opNeeded = true;

				sqlBuilder.Add(columnNames[i])
					.Add(" is not null");
			}

			if (columnNames.Length > 1)
			{
				sqlBuilder.Insert(0, "(");
				sqlBuilder.Add(")");
			}

			return sqlBuilder.ToSqlString();
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:30,代码来源:NotNullExpression.cs


示例8: ToSqlString

        public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
        {
            if (_criteria.Count == 0)
            {
                return EmptyExpression;
            }

            //TODO: add default capacity
            SqlStringBuilder sqlBuilder = new SqlStringBuilder();

            sqlBuilder.Add("(");

            for (int i = 0; i < _criteria.Count - 1; i++)
            {
                sqlBuilder.Add(
                    ((ICriterion) _criteria[i]).ToSqlString(criteria, criteriaQuery, enabledFilters));
                sqlBuilder.Add(Op);
            }

            sqlBuilder.Add(
                ((ICriterion) _criteria[_criteria.Count - 1]).ToSqlString(criteria, criteriaQuery, enabledFilters));

            sqlBuilder.Add(")");

            return sqlBuilder.ToSqlString();
        }
开发者ID:zibler,项目名称:zibler,代码行数:26,代码来源:Junction.cs


示例9: ToSqlString

		/// <summary>
		/// Render a SqlString for the expression.
		/// </summary>
		/// <param name="criteria"></param>
		/// <param name="criteriaQuery"></param>
		/// <param name="enabledFilters"></param>
		/// <returns>
		/// A SqlString that contains a valid Sql fragment.
		/// </returns>
		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			criteriaQuery.AddUsedTypedValues(GetTypedValues(criteria, criteriaQuery));
			ISpatialDialect spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
			string[] columnsUsingProjection = criteriaQuery.GetColumnsUsingProjection(criteria, this.propertyName);
			IType typeUsingProjection = criteriaQuery.GetTypeUsingProjection(criteria, this.propertyName);
			if (typeUsingProjection.ReturnedClass != typeof(IGeometry))
			{
				throw new QueryException(string.Format("Type mismatch in {0}: {1} expected type {2}, actual type {3}", GetType(), this.propertyName, typeof(IGeometry), typeUsingProjection.ReturnedClass));
			}
			if (typeUsingProjection.IsCollectionType)
			{
				throw new QueryException(string.Format("cannot use collection property ({0}.{1}) directly in a criterion, use ICriteria.CreateCriteria instead", criteriaQuery.GetEntityName(criteria), this.propertyName));
			}
			SqlStringBuilder builder = new SqlStringBuilder(2 * columnsUsingProjection.Length);
			for (int i = 0; i < columnsUsingProjection.Length; i++)
			{
				if (i > 0)
				{
					builder.Add(" AND ");
				}
				builder.Add(spatialDialect.GetSpatialValidationString(columnsUsingProjection[i], this.validation, true));
			}
			return builder.ToSqlString();
		}
开发者ID:cdromka,项目名称:sonar-csharp,代码行数:34,代码来源:SpatialValidationCriterion.cs


示例10: ToSqlString

		/// <summary>
		/// Render a SqlString for the expression.
		/// </summary>
		/// <param name="criteria"></param>
		/// <param name="criteriaQuery"></param>
		/// <param name="enabledFilters"></param>
		/// <returns>
		/// A SqlString that contains a valid Sql fragment.
		/// </returns>
		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			criteriaQuery.AddUsedTypedValues(GetTypedValues(criteria, criteriaQuery));
			ISpatialDialect spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
			string[] columns1 = GetColumnNames(criteria, criteriaQuery, this.propertyName);
			string[] columns2 = null;
			if (!(this.anotherGeometry is IGeometry))
			{
				columns2 = GetColumnNames(criteria, criteriaQuery, (string)this.anotherGeometry);
			}

			SqlStringBuilder builder = new SqlStringBuilder(10 * columns1.Length);
			for (int i = 0; i < columns1.Length; i++)
			{
				if (i > 0)
				{
					builder.Add(" AND ");
				}
				if (this.anotherGeometry is IGeometry)
				{
					builder.Add(spatialDialect.GetSpatialRelationString(columns1[i], this.relation, Parameter.Placeholder, true));
				}
				else
				{
					builder.Add(spatialDialect.GetSpatialRelationString(columns1[i], this.relation, columns2[i], true));
				}
			}
			return builder.ToSqlString();
		}
开发者ID:cdromka,项目名称:sonar-csharp,代码行数:38,代码来源:SpatialRelationCriterion.cs


示例11: FilterFacet

        public FilterFacet(string name, ICriteria filter)
        {
            Argument.EnsureNotBlank("name", name);

            this.name = name;
            this.filter = filter;
        }
开发者ID:pickypg,项目名称:ElasticLINQ,代码行数:7,代码来源:FilterFacet.cs


示例12: GetTypedValues

		public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			if (projection != null)
				return projection.GetTypedValues(criteria, criteriaQuery);
			
			return base.GetTypedValues(criteria, criteriaQuery);
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:7,代码来源:AggregateProjection.cs


示例13: Join

        protected Join(IDictionary<string, Join> joins, string toTable, string alias, ICriteria onCriteria)
            : base(toTable, alias)
        {
            this.joins = joins;
            this.onCriteria = onCriteria;

            if (!ReferenceEquals(this.onCriteria, null))
            {
                var aliases = JoinAliasLocator.Locate(this.onCriteria.ToStringIgnoreParams());
                if (aliases != null && aliases.Count > 0)
                    referencedAliases = aliases;
            }

            var toTableAliases = JoinAliasLocator.Locate(this.Table);
            if (toTableAliases != null && toTableAliases.Count > 0)
            {
                if (referencedAliases == null)
                    referencedAliases = toTableAliases;
                else
                {
                    foreach (var x in toTableAliases)
                        referencedAliases.Add(x);
                }
            }

            if (joins != null)
            {
                if (joins.ContainsKey(this.Name))
                    throw new ArgumentException(String.Format(
                        "There is already a join with alias '{0}'", this.Name));

                joins.Add(this.Name, this);
            }
        }
开发者ID:VictorTomaili,项目名称:Sanity,代码行数:34,代码来源:Join.cs


示例14: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery,
		                                      IDictionary<string, IFilter> enabledFilters)
		{
			ISQLFunction sqlFunction = GetFunction(criteriaQuery);
			List<string> tokens = new List<string>();
			string replacemenToken = Guid.NewGuid().ToString("n");
			for (int i = 0; i < args.Length; i++)
			{
				tokens.Add(replacemenToken);
			}
			string functionStatement = sqlFunction.Render(tokens, criteriaQuery.Factory).ToString();
			string[] splitted = functionStatement.Split(new string[] {replacemenToken}, StringSplitOptions.RemoveEmptyEntries);

			SqlStringBuilder sb = new SqlStringBuilder();
			for (int i = 0; i < splitted.Length; i++)
			{
				sb.Add(splitted[i]);
				if (i < args.Length)
				{
					int loc = (position + 1) * 1000 + i;
					SqlString projectArg = GetProjectionArgument(criteriaQuery, criteria, args[i], loc, enabledFilters);
					sb.Add(projectArg);
				}
			}
			sb.Add(" as ");
			sb.Add(GetColumnAliases(position)[0]);
			return sb.ToSqlString();
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:28,代码来源:SqlFunctionProjection.cs


示例15: GetRootCriteria

 private static CriteriaImpl GetRootCriteria(ICriteria criteria)
 {
     CriteriaImpl impl = criteria as CriteriaImpl;
     if (impl != null)
         return impl;
     return GetRootCriteria(((CriteriaImpl.Subcriteria)criteria).Parent);
 }
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:7,代码来源:CriteriaUtil.cs


示例16: ToSqlString

		/// <summary>
		/// Render the SQL fragment
		/// </summary>
		public virtual string ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			string[] columns = criteriaQuery.GetColumnAliasesUsingProjection(criteria, propertyName);

			StringBuilder fragment = new StringBuilder();

			ISessionFactoryImplementor factory = criteriaQuery.Factory;
			for (int i = 0; i < columns.Length; i++)
			{
				// TODO H3: bool lower = _ignoreCase && type.SqlTypes( factory )[ i ] == Types.VARCHAR
				bool lower = false;
				if (lower)
				{
					fragment.Append(factory.Dialect.LowercaseFunction)
						.Append('(');
				}
				fragment.Append(columns[i]);

				if (lower)
				{
					fragment.Append(')');
				}

				fragment.Append(ascending ? " asc" : " desc");

				if (i < columns.Length - 1)
				{
					fragment.Append(", ");
				}
			}

			return fragment.ToString();
		}
开发者ID:pallmall,项目名称:WCell,代码行数:36,代码来源:Order.cs


示例17: GetTypedValues

		public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			if (projection == null)
				return NoValues;
			else
				return projection.GetTypedValues(criteria, criteriaQuery);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:7,代码来源:NotNullExpression.cs


示例18: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			//TODO: add default capacity
			SqlStringBuilder sqlBuilder = new SqlStringBuilder();
			SqlString[] columnNames =
				CriterionUtil.GetColumnNames(propertyName, projection, criteriaQuery, criteria, enabledFilters);

			if (columnNames.Length != 1)
			{
				throw new HibernateException("insensitive like may only be used with single-column properties");
			}

			if (criteriaQuery.Factory.Dialect is PostgreSQLDialect)
			{
				sqlBuilder.Add(columnNames[0]);
				sqlBuilder.Add(" ilike ");
			}
			else
			{
				sqlBuilder.Add(criteriaQuery.Factory.Dialect.LowercaseFunction)
					.Add("(")
					.Add(columnNames[0])
					.Add(")")
					.Add(" like ");
			}

			sqlBuilder.AddParameter();

			return sqlBuilder.ToSqlString();
		}
开发者ID:juanplopes,项目名称:nhibernate,代码行数:30,代码来源:InsensitiveLikeExpression.cs


示例19: BuildCriteria

        private JObject BuildCriteria(ICriteria criteria)
        {
            if (criteria is RangeCriteria)
                return Build((RangeCriteria)criteria);

            if (criteria is RegexpCriteria)
                return Build((RegexpCriteria)criteria);

            if (criteria is PrefixCriteria)
                return Build((PrefixCriteria)criteria);

            if (criteria is TermCriteria)
                return Build((TermCriteria)criteria);

            if (criteria is TermsCriteria)
                return Build((TermsCriteria)criteria);

            if (criteria is NotCriteria)
                return Build((NotCriteria)criteria);

            if (criteria is QueryStringCriteria)
                return Build((QueryStringCriteria)criteria);

            // Base class formatters using name property

            if (criteria is SingleFieldCriteria)
                return Build((SingleFieldCriteria)criteria);

            if (criteria is CompoundCriteria)
                return Build((CompoundCriteria)criteria);

            throw new InvalidOperationException(String.Format("Unknown criteria type {0}", criteria.GetType()));
        }
开发者ID:diwakarpp,项目名称:ElasticLINQ,代码行数:33,代码来源:PostBodyRequestFormatter.cs


示例20: ToSqlString

		public SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			//SqlString result = new SqlString(criteriaQuery.GetSQLAlias(criteria));
			//result.Replace(sql, "{alias}");
			//return result;
			return new SqlString(StringHelper.Replace(sql, "{alias}", criteriaQuery.GetSQLAlias(criteria)));
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:7,代码来源:SQLProjection.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICriteriaQuery类代码示例发布时间:2022-05-24
下一篇:
C# ICredentials类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap