From 3270898c598fa4b0ce4cd64ab1f887d44114d253 Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Fri, 9 Feb 2024 14:51:57 -0800 Subject: [PATCH] Fallback `ToListAsync()` to `.ToList()` when `IAsyncEnumerable` is not available --- Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs index 70279db6fe..4a477036b2 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs @@ -1459,6 +1459,9 @@ public static Task SumAsync(this IQueryable source, public static async Task> ToListAsync(this IQueryable source, CancellationToken cancellationToken = default) { + if (source is not IAsyncEnumerable) { + return source.ToList(); + } var list = new List(); var asyncSource = source.AsAsyncEnumerable().WithCancellation(cancellationToken).ConfigureAwaitFalse(); await foreach (var element in asyncSource) {