File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
src/Microsoft.Data.SqlClient
netcore/src/Microsoft/Data/SqlClient
netfx/src/Microsoft/Data/SqlClient
tests/ManualTests/SQL/DataReaderTest Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -508,6 +508,10 @@ internal SqlBinary SqlBinary
508508 {
509509 if ( StorageType . SqlBinary == _type )
510510 {
511+ if ( IsNull )
512+ {
513+ return SqlBinary . Null ;
514+ }
511515 return ( SqlBinary ) _object ;
512516 }
513517 return ( SqlBinary ) SqlValue ; // anything else we haven't thought of goes through boxing.
Original file line number Diff line number Diff line change @@ -490,6 +490,10 @@ internal SqlBinary SqlBinary
490490 {
491491 if ( StorageType . SqlBinary == _type )
492492 {
493+ if ( IsNull )
494+ {
495+ return SqlBinary . Null ;
496+ }
493497 return ( SqlBinary ) _object ;
494498 }
495499 return ( SqlBinary ) SqlValue ; // anything else we haven't thought of goes through boxing.
Original file line number Diff line number Diff line change @@ -282,6 +282,14 @@ public static void CheckNullRowVersionIsBDNull()
282282 Assert . IsType < DBNull > ( result ) ;
283283 Assert . Equal ( result , reader . GetFieldValue < DBNull > ( 0 ) ) ;
284284 Assert . Throws < SqlNullValueException > ( ( ) => reader . GetFieldValue < byte [ ] > ( 0 ) ) ;
285+
286+ SqlBinary binary = reader . GetSqlBinary ( 0 ) ;
287+ Assert . True ( binary . IsNull ) ;
288+
289+ SqlBytes bytes = reader . GetSqlBytes ( 0 ) ;
290+ Assert . True ( bytes . IsNull ) ;
291+ Assert . Null ( bytes . Buffer ) ;
292+
285293 }
286294 finally
287295 {
You can’t perform that action at this time.
0 commit comments