public AsyncDataReaderEnumerable(IAsyncDataReader reader, CancellationToken ct) { this._ct = ct; Task = Task.Run(async() => { var nextResultTask = reader.NextResultAsync(); while ((await Task.WhenAll(nextResultTask))[0] && nextResultTask.Result) { nextResultTask = reader.NextResultAsync(); while (reader.Read()) { Object[] row = new Object[reader.FieldCount]; reader.GetValues(row); for (int i = 0; i < reader.FieldCount; i++) { if (row[i] is DBNull) { row[i] = GetDefaultValue(reader.GetFieldType(i)); } } Items.Add(row); } } }, this._ct); }
protected virtual void Dispose(bool disposing) { if (!disposing || _disposed) { return; } _disposed = true; _position = 0; _current = null; if (_reader != null) { _reader.Dispose(); } _reader = null; if (_command != null) { _command.Dispose(); } // queries do not modify state and thus calling Complete() on a so-called 'failed' query only // allows any outer transaction scope to decide the fate of the transaction if (_scope != null) { _scope.Complete(); // caller will dispose scope. } foreach (var dispose in _disposable) { dispose.Dispose(); } }
private async Task <bool> MoveToNextRecord() { if (_pageSize > 0 && _position >= _pageSize) { _command.SetParameter(_dialect.Skip, _position); _nextpage(_command, _current); } _reader = _reader ?? (await OpenNextPage()); if (await _reader.ReadAsync()) { return(IncrementPosition()); } if (!PagingEnabled()) { return(false); } if (!PageCompletelyEnumerated()) { return(false); } Logger.Verbose(Messages.EnumeratedRowCount, _position); _reader.Dispose(); _reader = await OpenNextPage(); //r.GetStreamToSnapshot() if (await _reader.ReadAsync()) { return(IncrementPosition()); } return(false); }