System.InvalidOperationException: The provider for the source IQueryable doesn't implement IDbAsyncQueryProvider. Only providers that implement IDbAsyncQueryProvider can be used for Entity Framework asynchronous operations. For more details see http://go.microsoft.com/fwlink/?LinkId=287068.
我的存储库看起来像:
namespace myApp.EntityFramework.Repositories
{
  public class TruckRepository : UHaulTrucks.HoustonRepositoryBase<DailyDockQuery>, ITruckRepository
  {
    public TruckRepository(IDbContextProvider<UHaulHoustonDbContext> dbContextProvider) : base(dbContextProvider)
    {
    }
 public IQueryable<DailyDockQuery> GetDailyDockQuery()
    {
      var ret = Context.Database.SqlQuery<DailyDockQuery>("exec Central_DailyDockQuery").AsQueryable();
      return ret;
    }
  }
}
以及我的服务:
public async Task<PagedResultOutput<DailyDockQueryListDto>> GetDailyDockQuery()
    {
      var query = _truckRepository.GetDailyDockQuery();
      var dailyCount = await query.CountAsync();
      var dailies = await query.ToListAsync();
      var dailiesDtos = dailies.MapTo<List<DailyDockQueryListDto>>();
      return new PagedResultOutput<DailyDockQueryListDto>(
        dailyCount,
        dailiesDtos
        );
    }
上述错误将在任何尝试执行异步方法时生成,例如:
var dailyCount = await query.CountAsync();
或
var dailies = await query.ToListAsync();
正如我所提到的,我在存储库和服务中尝试了几种不同的方法,使用任务和异步组合,结果相同。我对以这种方式实现自定义存储库很陌生,虽然我应该从IRepository获得CountAsync和ToListAsync的好处,但我怀疑我仍然需要在自定义类中实现它们。
非常感谢您的帮助。我还在这里找路。