【发布时间】:2021-10-29 04:28:45
【问题描述】:
我正在使用 EF 并在 Linq 查询 where 子句中尝试将今天的日期与 Azure SQL Server 数据库表中的日期列进行比较。
表格中的列:
模型类中的字段:
public DateTime OrderDate { get; set; }
我尝试了多种不同的方法来检查 Linq 查询中的 OrderDate = today's date 是否有任何返回结果,即使订单上有今天的日期
下面是我的 linq 查询
var orderData = from mo in _context.MOrders
from cus in _context.Customers
where mo.CustomerId == cus.CustomerId
&& mo.OrderDate == DateTime.Today.Date
我也试过mo.OrderDate.Date == DateTime.Today.Date,但没有返回记录
【问题讨论】:
标签: c# entity-framework linq entity-framework-core asp.net-core-mvc