public TColumn GetSpatialColumnValueWithErrorHandling <TColumn>(int ordinal, PrimitiveTypeKind spatialTypeKind) { Debug.Assert( spatialTypeKind == PrimitiveTypeKind.Geography || spatialTypeKind == PrimitiveTypeKind.Geometry, "Spatial primitive type kind is not geography or geometry?"); TColumn result; if (spatialTypeKind == PrimitiveTypeKind.Geography) { if (Streaming) { result = new ColumnErrorHandlingValueReader <TColumn>( (reader, column) => (TColumn)(object)_spatialReader.Value.GetGeography(column), (reader, column) => _spatialReader.Value.GetGeography(column) ).GetValue(Reader, ordinal); } else { result = new ColumnErrorHandlingValueReader <TColumn>( (reader, column) => (TColumn)Reader.GetValue(column), (reader, column) => Reader.GetValue(column) ).GetValue(Reader, ordinal); } } else { if (Streaming) { result = new ColumnErrorHandlingValueReader <TColumn>( (reader, column) => (TColumn)(object)_spatialReader.Value.GetGeometry(column), (reader, column) => _spatialReader.Value.GetGeometry(column) ).GetValue(Reader, ordinal); } else { result = new ColumnErrorHandlingValueReader <TColumn>( (reader, column) => (TColumn)Reader.GetValue(column), (reader, column) => Reader.GetValue(column) ).GetValue(Reader, ordinal); } } return(result); }
// <summary> // Used to retrieve a column value with exception handling. Normally compiled // delegates directly call typed methods on the DbDataReader (e.g. GetInt32) // but when an exception occurs we retry using this method to potentially get // a more useful error message to the user. // </summary> public TColumn GetColumnValueWithErrorHandling <TColumn>(int ordinal) { var result = new ColumnErrorHandlingValueReader <TColumn>().GetValue(Reader, ordinal); return(result); }