Exemplo n.º 1
0
        /// <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)
        {
            var       spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
            string    column1        = criteriaQuery.GetColumn(criteria, this.propertyName);
            SqlString sqlString;

            if (IsBinaryOperation())
            {
                if (geometry != null)
                {
                    Parameter[] parameters = criteriaQuery.NewQueryParameter(this.GetTypedValues(criteria, criteriaQuery)[0]).ToArray();
                    sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, parameters.Single());
                }
                else
                {
                    string column2 = criteriaQuery.GetColumn(criteria, this.anotherPropertyName);
                    sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, column2);
                }
            }
            else
            {
                sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, null);
            }

            return(new SqlStringBuilder()
                   .Add(sqlString)
                   .Add(" as y")
                   .Add(position.ToString())
                   .Add("_")
                   .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());
        }
 /// <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 = spatialDialect.GetSpatialRelationString(column1, this.relation, column2, false);
     return new SqlStringBuilder()
         .Add(sqlString)
         .Add(" as y")
         .Add(position.ToString())
         .Add("_")
         .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      = spatialDialect.GetSpatialRelationString(column1, this.relation, column2, false);

            return(new SqlStringBuilder()
                   .Add(sqlString)
                   .Add(" as y")
                   .Add(position.ToString())
                   .Add("_")
                   .ToSqlString());
        }
        public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery,
                                              IDictionary <string, IFilter> enabledFilters)
        {
            SqlStringBuilder buf = new SqlStringBuilder().Add("count(");

            if (distinct)
            {
                buf.Add("distinct ");
            }
            string column;

            if (projection != null)
            {
                column =
                    SqlStringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, position, criteriaQuery,
                                                                                  enabledFilters)).ToString();
            }
            else
            {
                column = criteriaQuery.GetColumn(criteria, propertyName);
            }

            buf.Add(column).Add(") as y").Add(position.ToString()).Add("_");
            return(buf.ToSqlString());
        }
Exemplo n.º 6
0
        SqlString IProjection.ToSqlString(ICriteria criteria, Int32 position, ICriteriaQuery criteriaQuery, IDictionary <String, IFilter> enabledFilters)
        {
            var classMetadata = criteriaQuery.Factory.GetClassMetadata(this.rootEntity);
            var propertyNames = this.GetPropertyNames(classMetadata, criteriaQuery);
            var builder       = new SqlStringBuilder();

            for (var i = 0; i < propertyNames.Length; ++i)
            {
                var propertyName = propertyNames[i];
                var subcriteria  = criteria.GetCriteriaByAlias(this.alias);
                var columnName   = criteriaQuery.GetColumn(subcriteria, propertyName);

                builder.Add(columnName);
                builder.Add(" as ");
                builder.Add(propertyName);

                this.aliases.Add(propertyName);

                if (i < propertyNames.Length - 1)
                {
                    builder.Add(", ");
                }
            }
            return(builder.ToSqlString());
        }
		public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			if (!grouped)
			{
				throw new InvalidOperationException("not a grouping projection");
			}
			return new SqlString(criteriaQuery.GetColumn(criteria, propertyName));
		}
Exemplo n.º 8
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(criteriaQuery.GetColumn(criteria, propertyName)));
 }
Exemplo n.º 9
0
		public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			return new SqlString(new object[]
			                     	{
			                     		criteriaQuery.GetColumn(criteria, propertyName),
			                     		" as y",
			                     		loc.ToString(),
			                     		"_"
			                     	});
		}
        public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilter)
        {
            if (ParameterValues != null && ParameterValues.Length > 0)
            {
                var sql = new SqlStringBuilder();
                sql.Add(aggregate).Add("(");
                bool hasProperty  = false;
                bool hasParameter = false;

                for (int i = 0; i < ParameterValues.Length; i++)
                {
                    if (PropertyPosition == i)
                    {
                        if (i > 0)
                        {
                            sql.Add(", ");
                        }
                        sql.Add(criteriaQuery.GetColumn(criteria, propertyName)).Add(", ");
                        hasProperty = true;
                    }
                    else if (i > 0)
                    {
                        sql.Add(", ");
                    }

                    sql.Add(LinqUtil.SqlEncode(ParameterValues[i]));
                    hasParameter = true;
                }
                if (!hasProperty)
                {
                    if (hasParameter)
                    {
                        sql.Add(", ");
                    }
                    sql.Add(criteriaQuery.GetColumn(criteria, propertyName));
                }

                return(sql.Add(") as y").Add(loc.ToString()).Add("_").ToSqlString());
            }

            // if ParameterValues were not specified, we defer to the base functionality
            return(base.ToSqlString(criteria, loc, criteriaQuery, enabledFilter));
        }
Exemplo n.º 11
0
 public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
 {
     return(new SqlString(new object[]
     {
         criteriaQuery.GetColumn(criteria, propertyName),
         " as y",
         loc.ToString(),
         "_"
     }));
 }
		public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery)
		{
			return new SqlString(new object[]
			                     	{
			                     		criteriaQuery.GetColumn(criteria, propertyName),
			                     		" as y",
			                     		loc.ToString(),
			                     		"_"
			                     	});
		}
Exemplo n.º 13
0
		public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			if (!grouped)
			{
				return base.ToGroupSqlString(criteria, criteriaQuery, enabledFilters);
			}
			else
			{
				return new SqlString(criteriaQuery.GetColumn(criteria, propertyName));
			}
		}
		public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			if (!grouped)
			{
				return base.ToGroupSqlString(criteria, criteriaQuery);
			}
			else
			{
				return new SqlString(criteriaQuery.GetColumn(criteria, propertyName));
			}
		}
Exemplo n.º 15
0
        private void AddParameters(String propertyName, SqlStringBuilder sql, ICriteria criteria, ICriteriaQuery criteriaQuery)
        {
            bool hasProperty  = false;
            bool hasParameter = false;

            sql.Add(FunctionName).Add("(");

            if (ParameterValues != null && ParameterValues.Length > 0)
            {
                for (int i = 0; i < ParameterValues.Length; i++)
                {
                    if (PropertyPosition == i)
                    {
                        if (i > 0)
                        {
                            sql.Add(", ");
                        }
                        sql.Add(criteriaQuery.GetColumn(criteria, propertyName)).Add(", ");
                        hasProperty = true;
                    }
                    else if (i > 0)
                    {
                        sql.Add(", ");
                    }

                    sql.AddParameter();
                    hasParameter = true;
                }
            }
            if (!hasProperty)
            {
                if (hasParameter)
                {
                    sql.Add(", ");
                }
                sql.Add(criteriaQuery.GetColumn(criteria, propertyName));
            }

            sql.Add(")");
        }
        /// <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);
            SqlString       sqlString;

            if (this.IsBinaryOperation())
            {
                string column2 = criteriaQuery.GetColumn(criteria, this.anotherPropertyName);
                sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, column2);
            }
            else
            {
                sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, this.arguments);
            }
            return(new SqlStringBuilder()
                   .Add(sqlString)
                   .Add(" as y")
                   .Add(position.ToString())
                   .Add("_")
                   .ToSqlString());
        }
Exemplo n.º 17
0
        /// <summary>
        /// Render the SQL Fragment.
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="position"></param>
        /// <param name="criteriaQuery"></param>
        /// <returns></returns>
        public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery)
        {
            ISpatialDialect spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
            string          column1        = criteriaQuery.GetColumn(criteria, this.propertyName);
            SqlString       sqlString      = spatialDialect.GetSpatialValidationString(column1, this.validation, false);

            return(new SqlStringBuilder()
                   .Add(sqlString)
                   .Add(" as y")
                   .Add(position.ToString())
                   .Add("_")
                   .ToSqlString());
        }
Exemplo n.º 18
0
		public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			SqlStringBuilder buf = new SqlStringBuilder()
				.Add("count(");
			if (distinct)
			{
				buf.Add("distinct ");
			}
			buf.Add(criteriaQuery.GetColumn(criteria, propertyName))
				.Add(") as y")
				.Add(position.ToString())
				.Add("_");
			return buf.ToSqlString();
		}
Exemplo n.º 19
0
		public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			var buf = new SqlStringBuilder().Add("count(");
			if (distinct)
			{
				buf.Add("distinct ");
			}
			if (projection != null)
			{
				buf.Add(SqlStringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, position, criteriaQuery, enabledFilters)));
			}
			else
			{
				buf.Add(criteriaQuery.GetColumn(criteria, propertyName));
			}

			buf.Add(") as y").Add(position.ToString()).Add("_");
			return buf.ToSqlString();
		}
Exemplo n.º 20
0
        public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery)
        {
            if (projection == null)
            {
                return(new SqlString(aggregate, "(", criteriaQuery.GetColumn(criteria, propertyName), ") as y", loc.ToString(), "_"));
            }

            return(new SqlString(
                       aggregate,
                       "(",
                       SqlStringHelper.RemoveAsAliasesFromSql(
                           projection.ToSqlString(
                               criteria,
                               loc,
                               criteriaQuery)),
                       ") as y",
                       loc.ToString(),
                       "_"));
        }
Exemplo n.º 21
0
		public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			ISessionFactoryImplementor factory = criteriaQuery.Factory;
			SqlType[] sqlTypeCodes = NHibernateUtil.Double.SqlTypes(factory);
			string sqlType = factory.Dialect.GetCastTypeName(sqlTypeCodes[0]);

			var sql = new SqlStringBuilder().Add(aggregate).Add("(");
			sql.Add("cast(");
			if (projection != null)
			{
				sql.Add(SqlStringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters)));
			}
			else
			{
				sql.Add(criteriaQuery.GetColumn(criteria, propertyName));
			}
			sql.Add(" as ").Add(sqlType).Add(")");
			sql.Add(") as ").Add(GetColumnAliases(loc, criteria, criteriaQuery)[0]);
			return sql.ToSqlString();
		}
Exemplo n.º 22
0
        public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery)
        {
            var buf = new SqlStringBuilder().Add("count(");

            if (distinct)
            {
                buf.Add("distinct ");
            }
            if (projection != null)
            {
                buf.AddObject(CriterionUtil.GetColumnNameAsSqlStringPart(projection, criteriaQuery, criteria));
            }
            else
            {
                buf.Add(criteriaQuery.GetColumn(criteria, propertyName));
            }

            buf.Add(") as y").Add(position.ToString()).Add("_");
            return(buf.ToSqlString());
        }
Exemplo n.º 23
0
        public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery)
        {
            var buf = new SqlStringBuilder().Add("count(");

            if (distinct)
            {
                buf.Add("distinct ");
            }
            if (projection != null)
            {
                buf.Add(SqlStringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, position, criteriaQuery)));
            }
            else
            {
                buf.Add(criteriaQuery.GetColumn(criteria, propertyName));
            }

            buf.Add(") as y").Add(position.ToString()).Add("_");
            return(buf.ToSqlString());
        }
Exemplo n.º 24
0
 public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
 {
     if (projection != null)
     {
         return
             (new SqlString(new object[]
         {
             aggregate, "(",
             SqlStringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery,
                                                                           enabledFilters)), ") as y",
             loc.ToString(), "_"
         }));
     }
     else
     {
         return
             (new SqlString(new object[]
                            { aggregate, "(", criteriaQuery.GetColumn(criteria, propertyName), ") as y", loc.ToString(), "_" }));
     }
 }
Exemplo n.º 25
0
		public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
		{
			if (projection != null)
			{
				return
					new SqlString(new object[]
								  	{
								  		aggregate, "(",
								  		StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery,
								  																   enabledFilters)), ") as y",
								  		loc.ToString(), "_"
								  	});
			}
			else
			{
				return
					new SqlString(new object[]
								  	{aggregate, "(", criteriaQuery.GetColumn(criteria, propertyName), ") as y", loc.ToString(), "_"});
			}
		}
Exemplo n.º 26
0
		public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery,
		                                      IDictionary<string, IFilter> enabledFilters)
		{
			ISessionFactoryImplementor factory = criteriaQuery.Factory;
			SqlType[] sqlTypeCodes = NHibernateUtil.Double.SqlTypes(factory);
			string sqlType = factory.Dialect.GetCastTypeName(sqlTypeCodes[0]);
			string parameter;
			if (projection != null)
			{
				parameter =
					StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters)).ToString();
			}
			else
			{
				parameter = criteriaQuery.GetColumn(criteria, propertyName);
			}
			string expression = string.Format("{0}(cast({1} as {2})) as {3}", aggregate, parameter, sqlType,
			                                  GetColumnAliases(loc)[0]);
			return new SqlString(expression);
		}
Exemplo n.º 27
0
        public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery)
        {
            ISessionFactoryImplementor factory = criteriaQuery.Factory;

            SqlType[] sqlTypeCodes = NHibernateUtil.Double.SqlTypes(factory);
            string    sqlType      = factory.Dialect.GetCastTypeName(sqlTypeCodes[0]);

            var sql = new SqlStringBuilder().Add(aggregate).Add("(");

            sql.Add("cast(");
            if (projection != null)
            {
                sql.Add(SqlStringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery)));
            }
            else
            {
                sql.Add(criteriaQuery.GetColumn(criteria, propertyName));
            }
            sql.Add(" as ").Add(sqlType).Add(")");
            sql.Add(") as ").Add(GetColumnAliases(loc, criteria, criteriaQuery)[0]);
            return(sql.ToSqlString());
        }
Exemplo n.º 28
0
        public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery,
                                              IDictionary <string, IFilter> enabledFilters)
        {
            ISessionFactoryImplementor factory = criteriaQuery.Factory;

            SqlType[] sqlTypeCodes = NHibernateUtil.Double.SqlTypes(factory);
            string    sqlType      = factory.Dialect.GetCastTypeName(sqlTypeCodes[0]);
            string    parameter;

            if (projection != null)
            {
                parameter =
                    StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters)).ToString();
            }
            else
            {
                parameter = criteriaQuery.GetColumn(criteria, propertyName);
            }
            string expression = string.Format("{0}(cast({1} as {2})) as {3}", aggregate, parameter, sqlType,
                                              GetColumnAliases(loc)[0]);

            return(new SqlString(expression));
        }
        public override SqlString ToSqlString(ICriteria criteria, int loc, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilter)
        {
            if (ParameterValues != null && ParameterValues.Length > 0)
            {
                var sql = new SqlStringBuilder();
                sql.Add(aggregate).Add("(");
                bool hasProperty = false;
                bool hasParameter = false;

                for (int i = 0; i < ParameterValues.Length; i++)
                {
                    if (PropertyPosition == i)
                    {
                        if (i > 0) sql.Add(", ");
                        sql.Add(criteriaQuery.GetColumn(criteria, propertyName)).Add(", ");
                        hasProperty = true;
                    }
                    else if (i > 0)
                    {
                        sql.Add(", ");
                    }

                    sql.Add(LinqUtil.SqlEncode(ParameterValues[i]));
                    hasParameter = true;
                }
                if (!hasProperty)
                {
                    if (hasParameter) sql.Add(", ");
                    sql.Add(criteriaQuery.GetColumn(criteria, propertyName));
                }

                return sql.Add(") as y").Add(loc.ToString()).Add("_").ToSqlString();
            }

            // if ParameterValues were not specified, we defer to the base functionality
            return base.ToSqlString(criteria, loc, criteriaQuery, enabledFilter);
        }
 protected override SqlString ToLeftSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
 {
     return(new SqlString(criteriaQuery.GetColumn(criteria, propertyName)));
 }
        private void AddParameters(String propertyName, SqlStringBuilder sql, ICriteria criteria, ICriteriaQuery criteriaQuery)
        {
            bool hasProperty = false;
            bool hasParameter = false;

            sql.Add(FunctionName).Add("(");

            if (ParameterValues != null && ParameterValues.Length > 0)
            {
                for (int i = 0; i < ParameterValues.Length; i++)
                {
                    if (PropertyPosition == i)
                    {
                        if (i > 0) sql.Add(", ");
                        sql.Add(criteriaQuery.GetColumn(criteria, propertyName)).Add(", ");
                        hasProperty = true;
                    }
                    else if (i > 0)
                    {
                        sql.Add(", ");
                    }

                    sql.AddParameter();
                    hasParameter = true;
                }
            }
            if (!hasProperty)
            {
                if (hasParameter) sql.Add(", ");
                sql.Add(criteriaQuery.GetColumn(criteria, propertyName));
            }

            sql.Add(")");
        }
Exemplo n.º 32
0
		/// <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();
		}
        /// <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)
        {
            var spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
            string column1 = criteriaQuery.GetColumn(criteria, this.propertyName);
            SqlString sqlString;

            if (IsBinaryOperation())
            {
                if (geometry != null)
                {
                    Parameter[] parameters = criteriaQuery.NewQueryParameter(this.GetTypedValues(criteria, criteriaQuery)[0]).ToArray();
                    sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, parameters.Single());
                }
                else
                {
                    string column2 = criteriaQuery.GetColumn(criteria, this.anotherPropertyName);
                    sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, column2);
                }
            }
            else
            {
                sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, null);
            }

            return new SqlStringBuilder()
                .Add(sqlString)
                .Add(" as y")
                .Add(position.ToString())
                .Add("_")
                .ToSqlString();
        }
		protected override SqlString ToLeftSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
		{
			return new SqlString(criteriaQuery.GetColumn(criteria, propertyName));
		}
 /// <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);
     SqlString sqlString;
     if (this.IsBinaryOperation())
     {
         string column2 = criteriaQuery.GetColumn(criteria, this.anotherPropertyName);
         sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, column2);
     }
     else
     {
         sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, this.arguments);
     }
     return new SqlStringBuilder()
         .Add(sqlString)
         .Add(" as y")
         .Add(position.ToString())
         .Add("_")
         .ToSqlString();
 }