c# - Dotnet EF Core 2.1 在查询小数属性时抛出 QueryClientEvaluationWarning
问题描述
我有一个 C# 类 Loan,它映射到 SQL Server 数据库中的 Loans 表。我正在使用 DotNet EF Core 2.1。从我的代码与数据库交互。
public class Loan
{
public decimal Rate { get;set; }
// Other properties omitted for brevity
}
当我创建数据库连接时,我将其配置为在服务器端无法执行查询时引发异常,如下所示:
services.AddDbContext<DbContext>(options =>
options
.UseSqlServer(systemConfiguration.DatabaseConnectionString)
.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)));
问题是使用 LINQ 查询小数列时:
// Obtain DbContext from services
var loans = await dbContext.Loans.Where(l => l.Rate > 1.5m).ToListAsync();
由于无法在服务器端执行查询,因此引发异常。其他数字属性类型(例如 int)可以正常工作。
解决方案
在针对 SQL Server 运行时,似乎这实际上不是问题。问题出在我使用 SQLite 的集成测试中
推荐阅读
- ssl - Bitbucket 部署,通过 [my-public-ip] 端口 22 重置连接
- java - 实际上是什么 ServletConfig config=null; 在下面的代码中
- c# - ASP.NET 4.8 - 如何让类在自己的实例中运行?
- excel - vbNewLine 直到双击才反映?
- javascript - 将动态生成的 div 内容的副本发布到新页面
- javascript - views.py 中的 Django 并行函数或分步模板渲染
- django - Django Zoho SMTPAuthenticationError(535,b'身份验证失败')
- javascript - 显示用户数据数组
- slack - [slack][bolt app] 如何获取与当前请求关联的范围?
- node.js - 分页API,直到在nodejs中返回错误