コード例 #1
0
        /// <summary>
        /// Method to get the number of features in the datasource
        /// </summary>
        /// <returns>The number of features</returns>
        protected virtual int GetFeatureCountInternal()
        {
            using (var conn = CreateOpenDbConnection())
            {
                using (var command = conn.CreateCommand())
                {
                    var sql = new StringBuilder();
                    sql.AppendFormat("SELECT COUNT(*) FROM {0}", _dbUtility.DecorateTable(Schema, Table));
#pragma warning disable 612,618
                    if (!String.IsNullOrEmpty(DefinitionQuery))
                    {
                        sql.AppendFormat(" WHERE {0}", DefinitionQuery);
                    }
#pragma warning restore 612,618
                    else
                    {
                        sql.Append(FeatureColumns.GetWhereClause());
                    }

                    sql.Append(";");

                    command.CommandText = sql.ToString();
                    return((int)command.ExecuteScalar());
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the main select clause
        /// </summary>
        /// <param name="from">The from clause to use (if it is not schema.table)</param>
        /// <returns>The plain select clause without any constraints or order clauses</returns>
        public string GetSelectClause(string from)
        {
            if (string.IsNullOrEmpty(from))
            {
                from = _spatialDbUtility.DecorateTable(_provider.Schema, _provider.Table);
            }

            if (string.IsNullOrEmpty(_selectClause))
            {
                var sqlBuilder = new StringBuilder("SELECT ");
                sqlBuilder.Append(_spatialDbUtility.DecorateAs(_provider.ObjectIdColumn));

                foreach (var fc in this)
                {
                    if (!fc.Display)
                    {
                        continue;
                    }

                    sqlBuilder.AppendFormat(", {0}", _spatialDbUtility.DecorateAs(
                                                !string.IsNullOrEmpty(fc.Function) ? GetFunctionColumn(fc) : fc.Column,
                                                fc.As));
                }
                sqlBuilder.AppendFormat(", {0}", GetGeometryColumn(true));

                sqlBuilder.AppendFormat(" FROM {0}", from);

                _selectClause = sqlBuilder.ToString();
            }

            return(_selectClause);
        }
コード例 #3
0
 /// <summary>
 /// Method to generate a SQL-From statement for a bounding box query
 /// </summary>
 /// <param name="envelope">The envelope to query</param>
 /// <param name="command">The command object that is supposed to perform the query</param>
 /// <returns>A SQL From statement string</returns>
 protected virtual string GetFrom(Envelope envelope, DbCommand command)
 {
     return(_dbUtility.DecorateTable(_schema, _table));
 }