我正在使用返回 IAsyncEnumerable<> 的 async/await 方法从 SQL Server 数据库中检索行并通过 Web API .Net Core 3.0 接口提供它们。它工作正常,直到我超过 8192 行。对于超出该点的行,它会失败。我尝试了 3 个不同的表,每个表的行大小都非常不同。每次在产生 8192 行后发生故障。这是我看到的错误:
An unhandled exception occurred while processing the request.
InvalidOperationException: 'AsyncEnumerableReader' reached the configured maximum size of the buffer when enumerating a value of type 'Microsoft.EntityFrameworkCore.TestDatabase.TestDatabaseDbSet`1[TestNamespace.TestClass]'. This limit is in place to prevent infinite streams of 'IAsyncEnumerable<>' from continuing indefinitely. If this is not a programming mistake, consider ways to reduce the collection size, or consider manually converting 'Microsoft.EntityFrameworkCore.TestDatabase.TestDatabaseDbSet`1[TestNamespace.TestClass]' into a …Run Code Online (Sandbox Code Playgroud)