/// <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()); }
/// <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()); }
public SqlString GetSpatialValidationString(object geometry, SpatialValidation validation, bool criterion) { return(worker.GetSpatialValidationString(geometry, validation, criterion)); }