public void GetSpatialValueAsync_throws_OperationCanceledException_if_task_is_cancelled() { Assert.Throws <OperationCanceledException>( () => SpatialHelpers.GetSpatialValueAsync( new MetadataWorkspace(), new Mock <DbDataReader>().Object, TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Geography)), /* columnOrdinal */ 0, new CancellationToken(canceled: true)) .GetAwaiter().GetResult()); }
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)); }
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>()); }