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


C# ICriteriaQuery.GetColumnsUsingProjection方法代码示例

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


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

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

示例2: 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);

			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:Novthirteen,项目名称:sconit_timesseiko,代码行数:29,代码来源:NotNullExpression.cs

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

示例4: 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);

			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:Novthirteen,项目名称:sconit_timesseiko,代码行数:29,代码来源:InsensitiveLikeExpression.cs

示例5: ToSqlString

		/// <summary>
		/// Converts the SimpleExpression to a <see cref="SqlString"/>.
		/// </summary>
		/// <returns>A SqlString that contains a valid Sql fragment.</returns>
		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary enabledFilters)
		{
			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}",
				                         	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));
			}

			if (_ignoreCase)
			{
				if (columnNames.Length != 1)
				{
					throw new HibernateException(
						"case insensitive expression may only be applied to single-column properties: " +
						_propertyName);
				}

				return new SqlStringBuilder(6)
					.Add(criteriaQuery.Factory.Dialect.LowercaseFunction)
					.Add(StringHelper.OpenParen)
					.Add(columnNames[0])
					.Add(StringHelper.ClosedParen)
					.Add(Op)
					.AddParameter()
					.ToSqlString();
			}
			else
			{
				//TODO: add default capacity
				SqlStringBuilder sqlBuilder = new SqlStringBuilder(4 * columnNames.Length);

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

					sqlBuilder.Add(columnNames[i])
						.Add(Op)
						.AddParameter();
				}
				return sqlBuilder.ToSqlString();
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:61,代码来源:SimpleExpression.cs

示例6: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary enabledFilters)
		{
			string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, _lhsPropertyName);
			string[] otherColumnNames = criteriaQuery.GetColumnsUsingProjection(criteria, _rhsPropertyName);

			string result = string.Join(
				" and ",
				StringHelper.Add(columnNames, Op, otherColumnNames)
				);

			if (columnNames.Length > 1)
			{
				result = StringHelper.OpenParen + result + StringHelper.ClosedParen;
			}

			return new SqlString(result);
			//TODO: get SQL rendering out of this package!
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:18,代码来源:PropertyExpression.cs

示例7: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			string[] projection = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);

			return new SqlStringBuilder()
				.Add("(")
				.Add(projection[0])
				.Add(" + ")
				.AddParameter()
				.Add(") as ")
				.Add(GetColumnAliases(0)[0])
				.ToSqlString();
		}
开发者ID:juanplopes,项目名称:nhibernate,代码行数:13,代码来源:AddNumberProjection.cs

示例8: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			SqlStringBuilder s = new SqlStringBuilder();
			string[] cols = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
			for (int i = 0; i < cols.Length; i++)
			{
				s.Add(cols[i]);
				s.Add(" as y");
				s.Add((loc + i).ToString());
				s.Add("_");
				if (i < cols.Length - 1)
					s.Add(", ");
			}
			return s.ToSqlString();
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:15,代码来源:PropertyProjection.cs

示例9: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary enabledFilters)
		{
			IType type = criteriaQuery.GetTypeUsingProjection(criteria, _propertyName);
			if (type.IsCollectionType)
			{
				throw new QueryException("Cannot use collections with InExpression");
			}

			if (_values.Length == 0)
			{
				// "something in ()" is always false
				return new SqlString("1=0");
			}

			//TODO: add default capacity
			SqlStringBuilder result = new SqlStringBuilder();
			string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, _propertyName);

			// Generate SqlString of the form:
			// columnName1 in (values) and columnName2 in (values) and ...

			for (int columnIndex = 0; columnIndex < columnNames.Length; columnIndex++)
			{
				string columnName = columnNames[columnIndex];

				if (columnIndex > 0)
				{
					result.Add(" and ");
				}

				result
					.Add(columnName)
					.Add(" in (");

				for (int i = 0; i < _values.Length; i++)
				{
					if (i > 0)
					{
						result.Add(StringHelper.CommaSpace);
					}
					result.AddParameter();
				}

				result.Add(")");
			}

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

示例10: ToSqlString

        public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
        {
            string[] columns = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
            if (columns.Length != 1)
                throw new HibernateException("Like may only be used with single-column properties");

            SqlStringBuilder lhs = new SqlStringBuilder(6);

            if(ignoreCase)
            {
                Dialect.Dialect dialect = criteriaQuery.Factory.Dialect;
                lhs.Add(dialect.LowercaseFunction).Add(StringHelper.OpenParen).Add(columns[0]).Add(
                    StringHelper.ClosedParen);
            }
            else
                lhs.Add(columns[0]);
            lhs.Add(" like ").AddParameter();
            if (escapeChar.HasValue)
                lhs.Add(" escape '" + escapeChar + "'");
            return lhs.ToSqlString();
        }
开发者ID:zibler,项目名称:zibler,代码行数:21,代码来源:LikeExpression.cs

示例11: 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.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));
			}
			string[] keyColumns = criteriaQuery.GetIdentifierColumns(criteria);


			string entityType = criteriaQuery.GetEntityName(criteria, this.propertyName);
			AbstractEntityPersister entityPersister = (AbstractEntityPersister)criteriaQuery.Factory.GetEntityPersister(entityType);

			// Only one key column is assumed
			string keyColumn = keyColumns[0];
			string alias = criteriaQuery.GetSQLAlias(criteria, this.propertyName);
			string tableName = entityPersister.TableName;
			int aliasLength = alias.Length + 1;

			SqlStringBuilder builder = new SqlStringBuilder(10 * columnsUsingProjection.Length);
			for (int i = 0; i < columnsUsingProjection.Length; i++)
			{
				if (i > 0)
				{
					builder.Add(" AND ");
				}
				string geometryColumn = columnsUsingProjection[i].Remove(0, aliasLength);
				builder.Add(spatialDialect.GetSpatialFilterString(alias, geometryColumn, keyColumn, tableName));
			}
			return builder.ToSqlString();
		}
开发者ID:knorrus,项目名称:nhcontrib,代码行数:43,代码来源:SpatialFilterCriterion.cs

示例12: ToSqlString

		public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string,IFilter> enabledFilters)
		{
			//we only need this for SQL Server, and or large amount of values
            if ((criteriaQuery.Factory.Dialect is MsSql2005Dialect) == false || values.Length < maximumNumberOfParametersToNotUseXml)
			{
				return expr.ToSqlString(criteria, criteriaQuery, enabledFilters);
			}
			IType type = criteriaQuery.GetTypeUsingProjection(criteria, propertyName);
			if (type.IsCollectionType)
			{
				throw new QueryException("Cannot use collections with InExpression");
			}

			if (values.Length == 0)
			{
				// "something in ()" is always false
				return new SqlString("1=0");
			}

			SqlStringBuilder result = new SqlStringBuilder();
			string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);

			// Generate SqlString of the form:
			// columnName1 in (xml query) and columnName2 in (xml query) and ...
			criteriaQuery.AddUsedTypedValues(this.GetTypedValues(criteria, criteriaQuery));			

			for (int columnIndex = 0; columnIndex < columnNames.Length; columnIndex++)
			{
				string columnName = columnNames[columnIndex];

				if (columnIndex > 0)
				{
					result.Add(" and ");
				}
				SqlType sqlType = type.SqlTypes(criteriaQuery.Factory)[columnIndex];
				result
					.Add(columnName)
					.Add(" in (")
					.Add("SELECT ParamValues.Val.value('.','")
					.Add(criteriaQuery.Factory.Dialect.GetTypeName(sqlType))
					.Add("') FROM ")
					.AddParameter()
					.Add(".nodes('/items/val') as ParamValues(Val)")
					.Add(")");
			}

			return result.ToSqlString();
		}
开发者ID:Dreameris,项目名称:.NET-Common-Library,代码行数:48,代码来源:XmlIn.cs

示例13: GetColumnNames

 /// <summary>
 /// Gets the column names.
 /// </summary>
 /// <param name="criteria">The criteria.</param>
 /// <param name="criteriaQuery">The criteria query.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <returns></returns>
 private string[] GetColumnNames(ICriteria criteria, ICriteriaQuery criteriaQuery, string propertyName)
 {
     string[] columns = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
     IType type = criteriaQuery.GetTypeUsingProjection(criteria, propertyName);
     if (type.ReturnedClass != typeof(IGeometry))
     {
         throw new QueryException(string.Format("Type mismatch in {0}: {1} expected type {2}, actual type {3}", base.GetType(), propertyName, typeof(IGeometry), type.ReturnedClass));
     }
     if (type.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 columns;
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:21,代码来源:SpatialRelationCriterion.cs


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