@@ -842,7 +842,7 @@ protected override void Dispose(bool disposing)
842
842
}
843
843
base . Dispose ( disposing ) ;
844
844
}
845
- catch ( SqlException ex )
845
+ catch ( SqlException ex )
846
846
{
847
847
SqlClientEventSource . Log . TryTraceEvent ( "SqlDataReader.Dispose | ERR | Error Message: {0}, Stack Trace: {1}" , ex . Message , ex . StackTrace ) ;
848
848
}
@@ -3771,26 +3771,18 @@ private bool TryReadColumnInternal(int i, bool readHeaderOnly = false)
3771
3771
_sharedState . _nextColumnDataToRead = _sharedState . _nextColumnHeaderToRead ;
3772
3772
_sharedState . _nextColumnHeaderToRead ++ ; // We read this one
3773
3773
3774
- if ( isNull )
3774
+ // Trigger new behavior for RowVersion to send DBNull.Value by allowing entry for Timestamp or discard entry for Timestamp for legacy support.
3775
+ // if LegacyRowVersionNullBehavior is enabled, Timestamp type must enter "else" block.
3776
+ if ( isNull && ( ! LocalAppContextSwitches . LegacyRowVersionNullBehavior || columnMetaData . type != SqlDbType . Timestamp ) )
3775
3777
{
3776
- if ( columnMetaData . type == SqlDbType . Timestamp )
3777
- {
3778
- if ( ! LocalAppContextSwitches . LegacyRowVersionNullBehavior )
3779
- {
3780
- _data [ i ] . SetToNullOfType ( SqlBuffer . StorageType . SqlBinary ) ;
3781
- }
3782
- }
3783
- else
3784
- {
3785
- TdsParser . GetNullSqlValue ( _data [ _sharedState . _nextColumnDataToRead ] ,
3778
+ TdsParser . GetNullSqlValue ( _data [ _sharedState . _nextColumnDataToRead ] ,
3786
3779
columnMetaData ,
3787
3780
_command != null ? _command . ColumnEncryptionSetting : SqlCommandColumnEncryptionSetting . UseConnectionSetting ,
3788
3781
_parser . Connection ) ;
3789
3782
3790
- if ( ! readHeaderOnly )
3791
- {
3792
- _sharedState . _nextColumnDataToRead ++ ;
3793
- }
3783
+ if ( ! readHeaderOnly )
3784
+ {
3785
+ _sharedState . _nextColumnDataToRead ++ ;
3794
3786
}
3795
3787
}
3796
3788
else
@@ -4102,8 +4094,8 @@ internal bool TrySetMetaData(_SqlMetaDataSet metaData, bool moreInfo)
4102
4094
4103
4095
if ( _parser != null )
4104
4096
{ // There is a valid case where parser is null
4105
- // Peek, and if row token present, set _hasRows true since there is a
4106
- // row in the result
4097
+ // Peek, and if row token present, set _hasRows true since there is a
4098
+ // row in the result
4107
4099
byte b ;
4108
4100
if ( ! _stateObj . TryPeekByte ( out b ) )
4109
4101
{
@@ -5015,7 +5007,7 @@ override public Task<T> GetFieldValueAsync<T>(int i, CancellationToken cancellat
5015
5007
{
5016
5008
_stateObj . _shouldHaveEnoughData = true ;
5017
5009
#endif
5018
- return Task . FromResult ( GetFieldValueInternal < T > ( i ) ) ;
5010
+ return Task . FromResult ( GetFieldValueInternal < T > ( i ) ) ;
5019
5011
#if DEBUG
5020
5012
}
5021
5013
finally
@@ -5109,7 +5101,7 @@ internal void CompletePendingReadWithFailure(int errorCode, bool resetForcePendi
5109
5101
5110
5102
#endif
5111
5103
5112
- internal abstract class SqlDataReaderAsyncCallContext < T > : AAsyncCallContext < SqlDataReader , T >
5104
+ internal abstract class SqlDataReaderAsyncCallContext < T > : AAsyncCallContext < SqlDataReader , T >
5113
5105
{
5114
5106
internal static readonly Action < Task < T > , object > s_completeCallback = CompleteAsyncCallCallback ;
5115
5107
0 commit comments