streamRows method

Stream<MssqlRow> streamRows(
  1. String sql, {
  2. Object parameters = const <String, Object?>{},
  3. MssqlQueryOptions options = MssqlQueryOptions.defaults,
  4. Duration? timeout,
  5. MssqlCancellationToken? cancellationToken,
  6. int? batchRows,
  7. int? maximumRows,
  8. int? maximumBytes,
})
inherited

Typed rows from a single row-producing result set, as they arrive.

Implementation

Stream<MssqlRow> streamRows(
  String sql, {
  Object parameters = const <String, Object?>{},
  MssqlQueryOptions options = MssqlQueryOptions.defaults,
  Duration? timeout,
  MssqlCancellationToken? cancellationToken,
  int? batchRows,
  int? maximumRows,
  int? maximumBytes,
}) async* {
  var resultSets = 0;
  await for (final event in stream(
    sql,
    parameters: parameters,
    options: options,
    timeout: timeout,
    cancellationToken: cancellationToken,
    batchRows: batchRows,
    maximumRows: maximumRows,
    maximumBytes: maximumBytes,
  )) {
    if (event is MssqlResultSetStart && ++resultSets > 1) {
      throw const MssqlException(
        type: MssqlErrorType.protocol,
        message: 'streamRows supports one row-producing result set.',
      );
    }
    if (event is MssqlRowBatch) {
      for (final row in event.rows) {
        yield row;
      }
    }
  }
}