You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a nutshell: ForEachAsync() takes Action<T> as second argument, but if I provide Func<T, Task> (async lambda) instead, the code still compiles. But obviously it will not work as expected, because the async lambdas will not be awaited.
The text was updated successfully, but these errors were encountered:
@andrewslavin thank you for making this request here.
We are currently holding off on adding any new functionality to the implementation of async enumerables we use, because we hope to integrate the work on the new async stream interfaces and language support that should be available in an upcoming version.
There are also deeper reasons why having an overload of ForEachAsync that takes a Func<TElement,Task> could be a pit of failure. These are detailed in dotnet/reactive#194 (comment) and are related to a high number of unnecessary Task allocations.
Other than that, if in the meanwhile you need something like this, it should be possible for you to create your own extension method to achieve it.
Take a look at how our ForEach extension method obtains the underlying IAsyncEnumerable (note that this requires using EF Core internal API that we will break for sure in EF Core 3.0):
And then you can implement a modified version of System.Interactive.Async's ForEachAsync that takes a Func<T, Task> and awaits on it on every step of the loop:
The issue, as well as the proposed solution, are described here: https://stackoverflow.com/questions/50920636/unexpected-behaviour-with-microsoft-entityframeworkcore-entityframeworkqueryable.
In a nutshell:
ForEachAsync()
takesAction<T>
as second argument, but if I provideFunc<T, Task>
(async lambda) instead, the code still compiles. But obviously it will not work as expected, because the async lambdas will not be awaited.The text was updated successfully, but these errors were encountered: