@@ -55,39 +55,43 @@ internal async Task<bool> NextResultAsync(IOBehavior ioBehavior, CancellationTok
55
55
VerifyNotDisposed ( ) ;
56
56
try
57
57
{
58
- while ( true )
58
+ do
59
59
{
60
- await m_resultSet ! . ReadEntireAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
61
- await ScanResultSetAsync ( ioBehavior , m_resultSet , cancellationToken ) . ConfigureAwait ( false ) ;
62
- if ( m_hasMoreResults && m_resultSet . ContainsCommandParameters )
63
- await ReadOutParametersAsync ( Command ! , m_resultSet , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
64
- else
65
- break ;
66
- }
60
+ while ( true )
61
+ {
62
+ await m_resultSet ! . ReadEntireAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
63
+ await ScanResultSetAsync ( ioBehavior , m_resultSet , cancellationToken ) . ConfigureAwait ( false ) ;
64
+ if ( m_hasMoreResults && m_resultSet . ContainsCommandParameters )
65
+ await ReadOutParametersAsync ( Command ! , m_resultSet , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
66
+ else
67
+ break ;
68
+ }
67
69
68
- if ( ! m_hasMoreResults )
69
- {
70
- if ( m_commandListPosition . CommandIndex < m_commandListPosition . Commands . Count )
70
+ if ( ! m_hasMoreResults )
71
71
{
72
- Command = m_commandListPosition . Commands [ m_commandListPosition . CommandIndex ] ;
73
- using ( Command . CancellableCommand . RegisterCancel ( cancellationToken ) )
72
+ if ( m_commandListPosition . CommandIndex < m_commandListPosition . Commands . Count )
74
73
{
75
- var writer = new ByteBufferWriter ( ) ;
76
- if ( ! Command . Connection ! . Session . IsCancelingQuery && m_payloadCreator . WriteQueryCommand ( ref m_commandListPosition , m_cachedProcedures ! , writer ) )
74
+ Command = m_commandListPosition . Commands [ m_commandListPosition . CommandIndex ] ;
75
+ using ( Command . CancellableCommand . RegisterCancel ( cancellationToken ) )
77
76
{
78
- using var payload = writer . ToPayloadData ( ) ;
79
- await Command . Connection . Session . SendAsync ( payload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
80
- await m_resultSet . ReadResultSetHeaderAsync ( ioBehavior ) . ConfigureAwait ( false ) ;
81
- ActivateResultSet ( ) ;
82
- m_hasMoreResults = true ;
77
+ var writer = new ByteBufferWriter ( ) ;
78
+ if ( ! Command . Connection ! . Session . IsCancelingQuery && m_payloadCreator . WriteQueryCommand ( ref m_commandListPosition , m_cachedProcedures ! , writer ) )
79
+ {
80
+ using var payload = writer . ToPayloadData ( ) ;
81
+ await Command . Connection . Session . SendAsync ( payload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
82
+ await m_resultSet . ReadResultSetHeaderAsync ( ioBehavior ) . ConfigureAwait ( false ) ;
83
+ ActivateResultSet ( ) ;
84
+ m_hasMoreResults = true ;
85
+ }
83
86
}
84
87
}
85
88
}
89
+ else
90
+ {
91
+ ActivateResultSet ( ) ;
92
+ }
86
93
}
87
- else
88
- {
89
- ActivateResultSet ( ) ;
90
- }
94
+ while ( m_hasMoreResults && ( Command ! . CommandBehavior & CommandBehavior . SingleRow ) != 0 ) ;
91
95
92
96
if ( ! m_hasMoreResults )
93
97
m_resultSet . Reset ( ) ;
0 commit comments