I'm constructing and executing my queries in a way that's independent of EF-Core, so I'm relying on IQueryable<T>
to obtain the required level of abstraction. I'm replacing awaited SingleAsync()
calls with awaited ToAsyncEnumerable().Single()
calls. I'm also replacing ToListAsync()
calls with ToAsyncEnumerable().ToList()
calls. But I just happened upon the ToAsyncEnumerable()
method so I'm unsure I'm using it correctly or not.
To clarify which extension methods I'm referring to, they're defined as follows:
SingleAsync
andToListAsync
are defined on theEntityFrameworkQueryableExtensions
class in theMicrosoft.EntityFrameworkCore
namespace and assembly.ToAsyncEnumerable
is defined on theAsyncEnumerable
class in theSystem.Linq
namespace in theSystem.Interactive.Async
assembly.
When the query runs against EF-Core, are the calls ToAsyncEnumerable().Single()/ToList()
versus SingleAsync()/ToListAsync()
equivalent in function and performance? If not then how do they differ?
ToAsyncEnumerable
in said assembly. – HappyNomad Nov 12 '16 at 9:08