c# - 为源类型“DbSet<>”找到了查询模式的多个实现。对“哪里”的模棱两可的呼唤
问题描述
我正在使用 EF Core 3.1.2,但出现以下错误
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public async Task<List<Client>> GetClients()
{
return await (from client in context.Client
select client).ToListAsync();
}
Multiple implementations of the query pattern were found for source type 'DbSet<>'. Ambiguous call to 'Where'
Multiple implementations of the query pattern were found for source type 'DbSet<>'. Ambiguous call to 'Select'
I get Ambiguous invocation:
System.Collections.Generic<IAsyncEnumerable>
System.Collections.Generic<IEnumerable>
System.Collections.Generic<IQuerable>
我没有任何方法可以覆盖上述内容。
解决方案
根据这个github线程:https ://github.com/dotnet/efcore/issues/18124
当前的解决方法是调用AsQueryable()
您的 DBSet。例如:
_context.YourDbSet.AsQueryable()
推荐阅读
- java - 线程“主”java.lang.NullPointerException 中的异常 - 在客户端。
(Client.java:64) 在 Client.main(Client.java:105) - javascript - 在 vue.js 中发布到烧瓶 API 时“被 CORS 策略阻止”
- hdl - 我正在尝试创建一个 8 位移位寄存器,但不太确定哪里出错了
- javascript - 对象检测(coco-ssd)Node.js:错误:传递给 tf.browser.fromPixels() 的像素必须是 HTMLVideoElement
- python - Python将元素附加到带有用户输入的二维数组
- python - PyInstaller .exe 运行后故障
- swift - SwiftUI FileDocument 使用 Sqlite 和 GRDB
- angular - Angular 主要捆绑包大小问题
- node.js - 来自 nodejs 的 Apple 钱包更新卡从 api 重新转换为 api 请求
- python - 使用 DFS 在 Python 中遍历地图