【发布时间】:2021-05-26 08:48:55
【问题描述】:
我在 vscode 中有一个带有 React 的 ASP.NET Core 3.1 项目。我的项目使用 Web API、Postgres、ReactJS。从 .Net 3.1 转换到 .Net 5.0 时,我在调试控制台中遇到此错误,而在运行 3.1 时不会出现此错误。特别是这些错误:
抛出异常:“System.InvalidOperationException”在 System.Private.CoreLib.dll 抛出异常: 'System.InvalidOperationException' 在 Npgsql.EntityFrameworkCore.PostgreSQL.dll 5 抛出异常: System.Private.CoreLib.dll 中的“System.InvalidOperationException” 已加载 'C:\Program 文件\dotnet\shared\Microsoft.NETCore.App\5.0.3\System.IO.MemoryMappedFiles.dll'。 跳过加载符号。模块经过优化和调试器选项 “只是我的代码”已启用。抛出异常: 'System.InvalidOperationException' 在 Npgsql.EntityFrameworkCore.PostgreSQL.dll 3 抛出异常: System.Private.CoreLib.dll 中的“System.InvalidOperationException”失败: Marketplace.Services.QueuedProcessingService[0] 执行错误 排队处理服务操作块中的请求。 System.InvalidOperationException:不支持“ILike”方法 因为查询已切换到客户端评估。这通常 当方法的参数无法转换为时发生 服务器。重写查询以避免客户端评估参数,因此 该方法可以翻译到服务器。
这是与之相关的代码:
private async Task Add(int statusCode, string url){
var responseErrorList = await responseErrorRepository.GetResponseErrorsAsync();
var responseError = responseErrorList.FirstOrDefault(re => EF.Functions.ILike(re.Url, url) && re.statusCode == statusCode);
}
private async Task UpdateError(ResponseError error, string url){
responseErrorRepository.Update(error);
var referrer = responseError.Referrers.FirstOrDefault(rer =>
EF.Functions.ILike(rer.Url, url));
}
后端是 ASP.NET Web API,前端是 React。网上资源好像不多,请问如何解决?谢谢!
【问题讨论】:
-
请分享您遇到此问题的代码
-
The 'ILike' method is not supported because the query has switched to client-evaluation.请发ILike方法。 -
抱歉,回复晚了!代码已添加!谢谢!
标签: c# reactjs asp.net-core asp.net-web-api