源“IQueryable”的提供程序未实现“IAsyncQueryProvider”

问题描述 投票:0回答:0

我正在尝试使用简单列表模拟一些数据库访问代码。它通常可以工作,但异步除外。这会导致错误提示提供者不支持 Iqueriable。我尝试了一些建议的解决方案,但它们似乎在执行 linq 查询时导致表达式错误


        [Fact]
        public async Task TestAsyncFromList()
        {
            
            List<int> items = new List<int>() { 1,2,3,4,5,6,7,8,9,10};
            var queryable = items.AsQueryable();
            var totalSync = queryable.Count();
            var totalAsync = await queryable.CountAsync(); // The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'
            Assert.True(totalSync==totalAsync);

        }

我期待有一个“AsAsyncQueiable”解决方案 试过这个源 IQueryable 的提供者没有实现 IAsyncQueryProvider - 但出现表达式错误

c# linq iqueryable
© www.soinside.com 2019 - 2024. All rights reserved.