The CsvWriter.WriteRecordsAsync overload for IAsyncEnumerable<T> creates an IAsyncEnumerator but does not dispose implementations not implementing IDisposable. When using EF Core with streaming results this leads to concurrent queries on the same DbContext. As this is not allowed e.g. for Postgres a Npgsql.NpgsqlOperationInProgressException is thrown on subsequent operations.
As IAsyncEnumerator implements IAsyncDisposable we should unconditionally await DisposeAsync.
The
CsvWriter.WriteRecordsAsync
overload forIAsyncEnumerable<T>
creates anIAsyncEnumerator
but does not dispose implementations not implementingIDisposable
. When using EF Core with streaming results this leads to concurrent queries on the same DbContext. As this is not allowed e.g. for Postgres a Npgsql.NpgsqlOperationInProgressException is thrown on subsequent operations. AsIAsyncEnumerator
implementsIAsyncDisposable
we should unconditionally await DisposeAsync.