I have a sync method which I'm trying to convert to async. Basically, the code below projects the data into a DTO, and selects rows and orders them based on properties of the DTO. It also gets only a certain 'page' of the data.
return GetDbContext().Items
.ProjectToQueryable<DTO>(automapperConfigProvider)
.Where({expression based on DTO})
.OrderBy({expression based on DTO}).ThenBy(...)
.Skip(skip)
.Take(take)
.ToList();
I tried to convert it like this but it fails on the ToListAsync
.
var query = GetDbContext().Items
.ProjectToQueryable<DTO>(automapperConfigProvider)
.Where({expression based on DTO})
.OrderBy({expression based on DTO}).ThenBy(...)
.Skip(skip)
.Take(take);
return await query.ToListAsync();
The exception I get is:
The source IQueryable doesn't implement IDbAsyncEnumerable. Only sources that implement IDbAsyncEnumerable can be used for Entity Framework asynchronous operations. For more details see http://go.microsoft.com/fwlink/?LinkId=287068.
I'm using EntityFramework, so the link in the exception does not make sense to me.
Has anyone encountered this?