Example #1
0
        // test to ensure that the SQL column has the expected SQL type.   Don't use the CLR type to avoid having to worry about differences in
        // type versions between the client and the database.
        private void EnsureGeographyColumn(int ordinal)
        {
            var fieldTypeName = _reader.GetDataTypeName(ordinal);

            if (!fieldTypeName.EndsWith(GeographySqlType, StringComparison.Ordinal))
            // Use EndsWith so that we just see the schema and type name, not the database name.
            {
                throw new InvalidDataException(Strings.SqlProvider_InvalidGeographyColumn(fieldTypeName));
            }
        }
        internal SqlSpatialDataReader(DbSpatialServices spatialServices, SqlDataReaderWrapper underlyingReader)
        {
            _spatialServices = spatialServices;
            _reader = underlyingReader;

            var fieldCount = _reader.FieldCount;
            _geographyColumns = new bool[fieldCount];
            _geometryColumns = new bool[fieldCount];
            for (var i = 0; i < _reader.FieldCount; i++)
            {
                var fieldTypeName = _reader.GetDataTypeName(i);
                // Use EndsWith so that we just see the schema and type name, not the database name.
                if (fieldTypeName.EndsWith(GeographySqlType, StringComparison.Ordinal))
                {
                    _geographyColumns[i] = true;
                }
                else if (fieldTypeName.EndsWith(GeometrySqlType, StringComparison.Ordinal))
                {
                    _geometryColumns[i] = true;
                }
            }
        }
        internal SqlSpatialDataReader(DbSpatialServices spatialServices, SqlDataReaderWrapper underlyingReader)
        {
            _spatialServices = spatialServices;
            _reader          = underlyingReader;

            var fieldCount = _reader.FieldCount;

            _geographyColumns = new bool[fieldCount];
            _geometryColumns  = new bool[fieldCount];
            for (var i = 0; i < _reader.FieldCount; i++)
            {
                var fieldTypeName = _reader.GetDataTypeName(i);
                // Use EndsWith so that we just see the schema and type name, not the database name.
                if (fieldTypeName.EndsWith(GeographySqlType, StringComparison.Ordinal))
                {
                    _geographyColumns[i] = true;
                }
                else if (fieldTypeName.EndsWith(GeometrySqlType, StringComparison.Ordinal))
                {
                    _geometryColumns[i] = true;
                }
            }
        }
 private void EnsureGeographyColumn(int ordinal)
 {
     if (!IsGeographyColumn(ordinal))
     {
         throw new InvalidDataException(Strings.SqlProvider_InvalidGeographyColumn(_reader.GetDataTypeName(ordinal)));
     }
 }