@@ -353,22 +353,38 @@ public Stream GetStream(int ordinal)
353
353
public decimal GetDecimal ( int ordinal )
354
354
{
355
355
var value = GetValue ( ordinal ) ;
356
- return value is float floatValue ? ( decimal ) floatValue :
357
- value is double decimalValue ? ( decimal ) decimalValue :
358
- ( decimal ) value ;
356
+ if ( value is decimal ) // happy flow
357
+ return ( decimal ) value ;
358
+
359
+ if ( value is double doubleValue )
360
+ return ( decimal ) doubleValue ;
361
+
362
+ if ( value is float floatValue )
363
+ return ( decimal ) floatValue ;
364
+
365
+ return ( decimal ) value ;
359
366
}
360
367
361
368
public double GetDouble ( int ordinal )
362
369
{
363
370
var value = GetValue ( ordinal ) ;
364
- return value is float floatValue ? floatValue :
365
- value is decimal decimalValue ? ( double ) decimalValue :
366
- ( double ) value ;
371
+ if ( value is double ) // happy flow
372
+ return ( double ) value ;
373
+
374
+ if ( value is float floatValue )
375
+ return floatValue ;
376
+
377
+ if ( value is decimal decimalValue )
378
+ return ( double ) decimalValue ;
379
+
380
+ return ( double ) value ;
367
381
}
368
382
369
383
public float GetFloat ( int ordinal )
370
384
{
371
385
var value = GetValue ( ordinal ) ;
386
+ if ( value is float ) // happy flow
387
+ return ( float ) value ;
372
388
373
389
// Loss of precision is expected, significant loss of information is not.
374
390
// Use explicit range checks to guard against that.
0 commit comments