Exemplo n.º 1
0
        internal static DbSpatialDataReader CreateSpatialDataReader(
            MetadataWorkspace workspace,
            DbDataReader reader)
        {
            StoreItemCollection itemCollection    = (StoreItemCollection)workspace.GetItemCollection(DataSpace.SSpace);
            DbSpatialDataReader spatialDataReader = itemCollection.ProviderFactory.GetProviderServices().GetSpatialDataReader(reader, itemCollection.ProviderManifestToken);

            if (spatialDataReader == null)
            {
                throw new ProviderIncompatibleException(Strings.ProviderDidNotReturnSpatialServices);
            }
            return(spatialDataReader);
        }
Exemplo n.º 2
0
        internal static object GetSpatialValue(
            MetadataWorkspace workspace,
            DbDataReader reader,
            TypeUsage columnType,
            int columnOrdinal)
        {
            DbSpatialDataReader spatialDataReader = SpatialHelpers.CreateSpatialDataReader(workspace, reader);

            if (Helper.IsGeographicType((PrimitiveType)columnType.EdmType))
            {
                return((object)spatialDataReader.GetGeography(columnOrdinal));
            }
            return((object)spatialDataReader.GetGeometry(columnOrdinal));
        }
Exemplo n.º 3
0
        internal static async Task <object> GetSpatialValueAsync(
            MetadataWorkspace workspace,
            DbDataReader reader,
            TypeUsage columnType,
            int columnOrdinal,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            DbSpatialDataReader spatialReader = SpatialHelpers.CreateSpatialDataReader(workspace, reader);

            if (Helper.IsGeographicType((PrimitiveType)columnType.EdmType))
            {
                return((object)await spatialReader.GetGeographyAsync(columnOrdinal, cancellationToken).WithCurrentCulture <DbGeography>());
            }
            return((object)await spatialReader.GetGeometryAsync(columnOrdinal, cancellationToken).WithCurrentCulture <DbGeometry>());
        }