private async Task <bool> BufferlessMoveNext(DbContext _, bool buffer, CancellationToken cancellationToken) { if (_dataReader == null) { await _relationalQueryContext.Connection.OpenAsync(cancellationToken); try { var relationalCommand = _shaperCommandContext .GetRelationalCommand(_relationalQueryContext.ParameterValues, _relationalQueryContext); await _relationalQueryContext.Connection .RegisterBufferableAsync(this, cancellationToken); _dataReader = await relationalCommand.ExecuteReaderAsync( _relationalQueryContext.Connection, _relationalQueryContext.ParameterValues, _relationalQueryContext.CommandLogger, cancellationToken); } catch { // If failure happens creating the data reader, then it won't be available to // handle closing the connection, so do it explicitly here to preserve ref counting. _relationalQueryContext.Connection.Close(); throw; } _dbDataReader = _dataReader.DbDataReader; _shaperCommandContext.NotifyReaderCreated(_dbDataReader); _valueBufferFactory = _shaperCommandContext.ValueBufferFactory; } var hasNext = await _dataReader.ReadAsync(cancellationToken); Current = hasNext ? _shaper.Shape(_relationalQueryContext, _valueBufferFactory.Create(_dbDataReader)) : default; if (buffer) { await BufferAllAsync(cancellationToken); } return(hasNext); }
private async Task <bool> BufferlessMoveNext(bool buffer, CancellationToken cancellationToken) { try { if (_dataReader == null) { await _relationalQueryContext.Connection.OpenAsync(cancellationToken); var relationalCommand = _shaperCommandContext .GetRelationalCommand(_relationalQueryContext.ParameterValues); await _relationalQueryContext.Connection .RegisterBufferableAsync(this, cancellationToken); _dataReader = await relationalCommand.ExecuteReaderAsync( _relationalQueryContext.Connection, _relationalQueryContext.ParameterValues, cancellationToken); _dbDataReader = _dataReader.DbDataReader; _shaperCommandContext.NotifyReaderCreated(_dbDataReader); _valueBufferFactory = _shaperCommandContext.ValueBufferFactory; } var hasNext = await _dataReader.ReadAsync(cancellationToken); Current = hasNext ? _shaper.Shape(_relationalQueryContext, _valueBufferFactory.Create(_dbDataReader)) : default(T); if (buffer) { await BufferAllAsync(cancellationToken); } return(hasNext); } catch (Exception) { _dataReader = null; _dbDataReader = null; throw; } }
private bool BufferlessMoveNext(DbContext _, bool buffer) { if (_dataReader == null) { _relationalQueryContext.Connection.Open(); try { var relationalCommand = _shaperCommandContext .GetRelationalCommand(_relationalQueryContext.ParameterValues); _relationalQueryContext.Connection.RegisterBufferable(this); _dataReader = relationalCommand.ExecuteReader( _relationalQueryContext.Connection, _relationalQueryContext.ParameterValues); } catch { // If failure happens creating the data reader, then it won't be available to // handle closing the connection, so do it explicitly here to preserve ref counting. _relationalQueryContext.Connection.Close(); throw; } _dbDataReader = _dataReader.DbDataReader; _shaperCommandContext.NotifyReaderCreated(_dbDataReader); _valueBufferFactory = _shaperCommandContext.ValueBufferFactory; } var hasNext = _dataReader.Read(); Current = hasNext ? _shaper.Shape(_relationalQueryContext, _valueBufferFactory.Create(_dbDataReader)) : default; if (buffer) { BufferAll(); } return(hasNext); }
private bool BufferlessMoveNext(bool buffer) { try { if (_dataReader == null) { _relationalQueryContext.Connection.Open(); var relationalCommand = _shaperCommandContext .GetRelationalCommand(_relationalQueryContext.ParameterValues); _relationalQueryContext.Connection.RegisterBufferable(this); _dataReader = relationalCommand.ExecuteReader( _relationalQueryContext.Connection, _relationalQueryContext.ParameterValues); _dbDataReader = _dataReader.DbDataReader; _shaperCommandContext.NotifyReaderCreated(_dbDataReader); _valueBufferFactory = _shaperCommandContext.ValueBufferFactory; } var hasNext = _dataReader.Read(); Current = hasNext ? _shaper.Shape(_relationalQueryContext, _valueBufferFactory.Create(_dbDataReader)) : default(T); if (buffer) { BufferAll(); } return(hasNext); } catch (Exception) { _dataReader = null; _dbDataReader = null; throw; } }