/// <summary> /// Function to generate a spatial where clause for the intersection queries. /// </summary> /// <param name="bbox">The geometry</param> /// <param name="command">The command object, that is supposed to execute the query.</param> /// <returns>The spatial component of a SQL where clause</returns> protected override string GetSpatialWhere(IGeometry bbox, DbCommand command) { var sqlCommand = (SqlCommand)command; #pragma warning disable 612,618 var pwhere = new SqlParameter("@PWhere", !string.IsNullOrEmpty(DefinitionQuery) ? DefinitionQuery : FeatureColumns.GetWhereClause(null)); #pragma warning restore 612,618 sqlCommand.Parameters.Add(pwhere); return(string.Format("{3} IN (SELECT _tmp_.{3} FROM ST.RelateQueryWhere('{0}', '{1}', {2}, 'Intersects', @PWhere) AS _tmp_)", Table, GeometryColumn, BuildGeometry(bbox, sqlCommand), DbUtility.DecorateColumn(ObjectIdColumn))); }