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


C# ICriteria类代码示例

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


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


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