Ejemplo n.º 1
0
        public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
        {
            //Implementation changed from H3.2 to use SqlString
            string[]    columns    = criteriaQuery.GetIdentifierColumns(criteria);
            Parameter[] parameters = GetTypedValues(criteria, criteriaQuery).SelectMany(t => criteriaQuery.NewQueryParameter(t)).ToArray();

            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(parameters, i, criteria, criteriaQuery, result);
            }

            if (columns.Length > 1)
            {
                result.Add(StringHelper.ClosedParen);
            }
            return(result.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();
		}
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
 {
     if (!grouped)
     {
         throw new InvalidOperationException("not a grouping projection");
     }
     return(new SqlString(StringHelper.Join(",", criteriaQuery.GetIdentifierColumns(criteria))));
 }
		public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			if (!grouped)
			{
				throw new InvalidOperationException("not a grouping projection");
			}
			return new SqlString(StringHelper.Join(",", criteriaQuery.GetIdentifierColumns(criteria)));
		}
 public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
 {
     if (!grouped)
     {
         throw new InvalidOperationException("not a grouping projection");
     }
     return(new SqlString(string.Join(",", criteriaQuery.GetIdentifierColumns(criteria))));
 }
Ejemplo n.º 7
0
        /// <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)
        {
            IEnumerable <Parameter> parameters = criteriaQuery.NewQueryParameter(GetParameterTypedValue(criteria, criteriaQuery));

            Parameter p = null;

            foreach (Parameter p_ in parameters)
            {
                p = p_;
            }

            //Parameter[] p = criteriaQuery.NewQueryParameter(GetTypedValues(criteria, criteriaQuery)[0]).ToArray();
            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, p));
            }
            return(builder.ToSqlString());
        }
		public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			SqlStringBuilder buf = new SqlStringBuilder();
			string[] cols = criteriaQuery.GetIdentifierColumns(criteria);
			for (int i = 0; i < cols.Length; i++)
			{
				if (i > 0)
				{
					buf.Add(", ");
				}

				buf.Add(cols[i])
					.Add(" as y")
					.Add((position + i).ToString())
					.Add("_");
			}
			return buf.ToSqlString();
		}
Ejemplo n.º 9
0
        public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
        {
            SqlStringBuilder buf = new SqlStringBuilder();

            string[] cols = criteriaQuery.GetIdentifierColumns(criteria);
            for (int i = 0; i < cols.Length; i++)
            {
                if (i > 0)
                {
                    buf.Add(", ");
                }

                buf.Add(cols[i])
                .Add(" as y")
                .Add((position + i).ToString())
                .Add("_");
            }
            return(buf.ToSqlString());
        }
Ejemplo n.º 10
0
		/// <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();
		}
Ejemplo n.º 11
0
		public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			return (grouped) ?
			       new SqlString(StringHelper.Join(",", criteriaQuery.GetIdentifierColumns(criteria)))
			       	: base.ToGroupSqlString(criteria, criteriaQuery,enabledFilters);
		}
		public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			return (grouped) ?
			       new SqlString(StringHelper.Join(",", criteriaQuery.GetIdentifierColumns(criteria)))
			       	: base.ToGroupSqlString(criteria, criteriaQuery);
		}