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

C# ICriteriaQuery类代码示例

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

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



ICriteriaQuery类属于命名空间,在下文中一共展示了ICriteriaQuery类的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)
		{
			ArrayList list = new ArrayList();
			IType type = criteriaQuery.GetTypeUsingProjection(criteria, _propertyName);

			if (type.IsComponentType)
			{
				IAbstractComponentType actype = (IAbstractComponentType) type;
				IType[] types = actype.Subtypes;

				for (int i = 0; i < types.Length; i++)
				{
					for (int j = 0; j < _values.Length; j++)
					{
						object subval = _values[j] == null ?
						                null :
						                actype.GetPropertyValues(_values[j])[i];
						list.Add(new TypedValue(types[i], subval));
					}
				}
			}
			else
			{
				for (int j = 0; j < _values.Length; j++)
				{
					list.Add(new TypedValue(type, _values[j]));
				}
			}

			return (TypedValue[]) list.ToArray(typeof(TypedValue));
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:31,代码来源:InExpression.cs


示例3: GetTypedValues

		public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			if (_projection != null)
				return _projection.GetTypedValues(criteria, criteriaQuery);
			
			return new TypedValue[] {criteriaQuery.GetTypedIdentifierValue(criteria, value)};
		}
开发者ID:juanplopes,项目名称:nhibernate,代码行数:7,代码来源:IdentifierEqExpression.cs


示例4: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			//Implementation changed from H3.2 to use SqlString
			string[] columns = criteriaQuery.GetIdentifierColumns(criteria);
			SqlStringBuilder result = new SqlStringBuilder(4 * columns.Length + 2);
			if (columns.Length > 1)
			{
				result.Add(StringHelper.OpenParen);
			}

			for (int i = 0; i < columns.Length; i++)
			{
				if (i > 0)
				{
					result.Add(" and ");
				}

				result.Add(columns[i])
					.Add(" = ");

				AddValueOrProjection(criteria, criteriaQuery, enabledFilters, result);
			}

			if (columns.Length > 1)
			{
				result.Add(StringHelper.ClosedParen);
			}
			return result.ToSqlString();
		}
开发者ID:juanplopes,项目名称:nhibernate,代码行数:29,代码来源:IdentifierEqExpression.cs


示例5: GetColumnNamesUsingPropertyName

		private static SqlString[] GetColumnNamesUsingPropertyName(
			ICriteriaQuery criteriaQuery, 
			ICriteria criteria, 
			string propertyName, 
			object value, 
			ICriterion critertion)
		{
			string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
			IType propertyType = criteriaQuery.GetTypeUsingProjection(criteria, propertyName);

			if (value != null && !(value is System.Type) && !propertyType.ReturnedClass.IsInstanceOfType(value))
			{
				throw new QueryException(string.Format(
											"Type mismatch in {0}: {1} expected type {2}, actual type {3}",
											critertion.GetType(), propertyName, propertyType.ReturnedClass, value.GetType()));
			}

			if (propertyType.IsCollectionType)
			{
				throw new QueryException(string.Format(
											"cannot use collection property ({0}.{1}) directly in a criterion,"
											+ " use ICriteria.CreateCriteria instead",
											criteriaQuery.GetEntityName(criteria), propertyName));
			}
			return Array.ConvertAll<string, SqlString>(columnNames, delegate(string col)
			{
				return new SqlString(col);
			});
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:29,代码来源:CriterionUtil.cs


示例6: 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


示例7: 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


示例8: 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


示例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[] 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


示例10: 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


示例11: 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


示例12: 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


示例13: ToSqlString

		/// <summary>
		/// Render the SQL Fragment.
		/// </summary>
		/// <param name="criteria"></param>
		/// <param name="position"></param>
		/// <param name="criteriaQuery"></param>
		/// <param name="enabledFilters"></param>
		/// <returns></returns>
		public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			ISpatialDialect spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
			string column1 = criteriaQuery.GetColumn(criteria, this.propertyName);
			string column2 = criteriaQuery.GetColumn(criteria, this.anotherPropertyName);

			SqlString sqlString;
			if (this.pattern == null)
			{
				sqlString = spatialDialect.GetSpatialRelateString(column1, column2, null, false, false);
			}
			else
			{
				string column3 = criteriaQuery.GetColumn(criteria, this.pattern);
				if (column3 == null)
				{
					sqlString = spatialDialect.GetSpatialRelateString(column1, column2, this.pattern, true, false);
				}
				else
				{
					sqlString = spatialDialect.GetSpatialRelateString(column1, column2, column3, false, false);
				}
			}
			return new SqlStringBuilder()
				.Add(sqlString)
				.Add(" as y")
				.Add(position.ToString())
				.Add("_")
				.ToSqlString();
		}
开发者ID:cdromka,项目名称:sonar-csharp,代码行数:38,代码来源:SpatialRelateProjection.cs


示例14: ToSqlString

		public SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery)
		{
			//SqlString result = new SqlString(criteriaQuery.GetSQLAlias(criteria));
			//result.Replace(sql, "{alias}");
			//return result;
			return new SqlString(StringHelper.Replace(sql, "{alias}", criteriaQuery.GetSQLAlias(criteria)));
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:7,代码来源:SQLProjection.cs


示例15: 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 sql.Substring(0, sql.LastIndexOfCaseInsensitive(" as "));
 }
开发者ID:pvginkel,项目名称:NHibernate.OData,代码行数:7,代码来源:OperatorProjection.cs


示例16: 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


示例17: 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


示例18: 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


示例19: ToSqlString

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

			string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, _propertyName);

			for (int i = 0; i < columnNames.Length; i++)
			{
				if (i > 0)
				{
					sqlBuilder.Add(" and ");
				}

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

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

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


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ICriterion类代码示例发布时间:2022-05-24
下一篇:
C# ICriteria类代码示例发布时间: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