Skip to content

Npgsql.NpgsqlException (0x80004005): Exception while reading from stream - 8.0.0 #5430

@yunfandev

Description

@yunfandev

The issue

var multi = await _dbContext.Database.GetDbConnection().QueryMultipleAsync(querySql + summarySql, paramters);
var items = await multi.ReadAsync<ItemModel>();
var summary = await multi.ReadFirstAsync<SummaryModel>();

After upgrading to 8.0, the third line of code runs with the following error:

System.InvalidOperationException: The reader is closed
   at void Npgsql.ThrowHelper.ThrowInvalidOperationException(string message)
   at void Npgsql.NpgsqlDataReader.CheckClosedOrDisposed()+Throw(ReaderState state)
   at async Task<bool> Npgsql.NpgsqlDataReader.NextResult(bool async, bool isConsuming, CancellationToken cancellationToken)
   at async Task Dapper.SqlMapper+GridReader.OnAfterGridAsync(int index) in /_/Dapper/SqlMapper.GridReader.Async.cs:line 148
   at async Task<IEnumerable<T>> Dapper.SqlMapper+GridReader.ReadBufferedAsync<T>(int index, Func<DbDataReader, object> deserializer) in /_/Dapper/SqlMapper.GridReader.Async.cs:line 246

Further technical details

Npgsql version: 8.0
PostgreSQL version: 15.3
Operating system: Debian 12 in Docker

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions