I am looking for an empty IQueryable<T>
that implements IAsyncEnumerable<T>
. My current code does not work because empty Enumerable
does not implement IAsyncEnumerable<T>
. Thanks for any help or hint.
I have the following design:
var result = Enumerable.Empty<Foo>().AsQueryable(); // Not working!
if (condition1)
{
IQueryable<Foo> part1 = ....;
result = result.Concat(part1);
}
if (condition2)
{
IQueryable<Foo> part2 = ....;
result = result.Concat(part2);
}
return await result.ToListAsync();
Error message:
The source IQueryable doesn't implement IAsyncEnumerable<Foo>. Only sources that implement IAsyncEnumerable can be used for Entity Framework asynchronous operations.
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AsAsyncEnumerable[TSource](IQueryable`1 source)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)