首页 新闻 会员 周边 捐助

升级到 .NET 10 后调用 System.Linq.AsyncEnumerable.Concat 的方法报错

0
悬赏园豆:30 [已解决问题] 解决于 2025-11-13 09:37

园子的博客系统从 .NET 9 升级到 .NET 10 后,下面的代码

return await blogStreams
    .Aggregate((acc, list) => acc.Concat(list))
    .OrderByDescending(p => p.DatePublished)
    .ToListAsync();

编译是报错

The call is ambiguous between the following methods or properties: 'System.Linq.AsyncEnumerable.Concat<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Collections.Generic.IAsyncEnumerable<TSource>)' and 'System.Linq.AsyncEnumerable.Concat<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Collections.Generic.IAsyncEnumerable<TSource>)'
dudu的主页 dudu | 高人七级 | 园豆:24466
提问于:2025-11-13 07:45
< >
分享
最佳答案
0

Breaking change - System.Linq.AsyncEnumerable in .NET 10 引起的

.NET 10 introduces the AsyncEnumerable class, which provides a full set of LINQ extension methods for the IAsyncEnumerable<T> type. This class replaces the community-maintained System.Linq.Async NuGet library, potentially causing compilation errors due to ambiguities.

移除 nuget 包 System.Interactive.Async 解决了

dotnet package remove System.Interactive.Async
dudu | 高人七级 |园豆:24466 | 2025-11-13 07:56

移除 System.Interactive.Async 后,项目中使用 ForEachAwaitAsync 的地方需要改回使用 await foreach

dudu | 园豆:24466 (高人七级) | 2025-11-13 09:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册