@@ -8,7 +8,7 @@ namespace Ydb.Sdk.Ado;
88
99public sealed class YdbDataReader : DbDataReader , IAsyncEnumerable < YdbDataRecord >
1010{
11- private readonly IAsyncEnumerator < ExecuteQueryResponsePart > _stream ;
11+ private readonly IServerStream < ExecuteQueryResponsePart > _stream ;
1212 private readonly YdbTransaction ? _ydbTransaction ;
1313 private readonly RepeatedField < IssueMessage > _issueMessagesInStream = new ( ) ;
1414 private readonly Action < Status > _onNotSuccessStatus ;
@@ -53,7 +53,7 @@ private enum State
5353 internal bool IsOpen => ReaderState is State . NewResultSet or State . ReadResultSet ;
5454
5555 private YdbDataReader (
56- IAsyncEnumerator < ExecuteQueryResponsePart > resultSetStream ,
56+ IServerStream < ExecuteQueryResponsePart > resultSetStream ,
5757 Action < Status > onNotSuccessStatus ,
5858 YdbTransaction ? ydbTransaction )
5959 {
@@ -63,7 +63,7 @@ private YdbDataReader(
6363 }
6464
6565 internal static async Task < YdbDataReader > CreateYdbDataReader (
66- IAsyncEnumerator < ExecuteQueryResponsePart > resultSetStream ,
66+ IServerStream < ExecuteQueryResponsePart > resultSetStream ,
6767 Action < Status > onStatus ,
6868 YdbTransaction ? ydbTransaction = null )
6969 {
@@ -75,7 +75,7 @@ internal static async Task<YdbDataReader> CreateYdbDataReader(
7575
7676 private async Task Init ( )
7777 {
78- if ( State . IsConsumed == await NextExecPart ( ) )
78+ if ( State . IsConsumed == await NextExecPart ( CancellationToken . None ) )
7979 {
8080 throw new YdbException ( "YDB server closed the stream" ) ;
8181 }
@@ -448,7 +448,7 @@ public override async Task<bool> NextResultAsync(CancellationToken cancellationT
448448 State . ReadResultSet => await new Func < Task < State > > ( async ( ) =>
449449 {
450450 State state ;
451- while ( ( state = await NextExecPart ( ) ) == State . ReadResultSet )
451+ while ( ( state = await NextExecPart ( cancellationToken ) ) == State . ReadResultSet )
452452 {
453453 }
454454
@@ -475,7 +475,7 @@ public override async Task<bool> ReadAsync(CancellationToken cancellationToken)
475475 return true ;
476476 }
477477
478- while ( ( ReaderState = await NextExecPart ( ) ) == State . ReadResultSet ) // reset _currentRowIndex
478+ while ( ( ReaderState = await NextExecPart ( cancellationToken ) ) == State . ReadResultSet ) // reset _currentRowIndex
479479 {
480480 if ( ++ _currentRowIndex < RowsCount )
481481 {
@@ -521,7 +521,7 @@ public override async Task CloseAsync()
521521 }
522522
523523 _onNotSuccessStatus ( new Status ( StatusCode . SessionBusy ) ) ;
524- await _stream . DisposeAsync ( ) ;
524+ _stream . Dispose ( ) ;
525525
526526 if ( _ydbTransaction != null )
527527 {
@@ -542,13 +542,13 @@ private YdbValue GetFieldYdbValue(int ordinal)
542542 : ydbValue ;
543543 }
544544
545- private async ValueTask < State > NextExecPart ( )
545+ private async ValueTask < State > NextExecPart ( CancellationToken cancellationToken )
546546 {
547547 try
548548 {
549549 _currentRowIndex = - 1 ;
550550
551- if ( ! await _stream . MoveNextAsync ( ) )
551+ if ( ! await _stream . MoveNextAsync ( cancellationToken ) )
552552 {
553553 return State . IsConsumed ;
554554 }
@@ -561,7 +561,7 @@ private async ValueTask<State> NextExecPart()
561561 {
562562 OnFailReadStream ( ) ;
563563
564- while ( await _stream . MoveNextAsync ( ) )
564+ while ( await _stream . MoveNextAsync ( cancellationToken ) )
565565 {
566566 _issueMessagesInStream . AddRange ( _stream . Current . Issues ) ;
567567 }
0 commit comments