我正在尝试创建一个列表,如下所示。
出于某种原因,它遵循前两个条件,isPublished 和 IsRPG == false。 但它忽略了货架日期。
我想要所有货架日期大于或等于当前日期的游戏。
但它会显示具有任何货架日期的游戏......
BTW 货架日期的类型是日期时间。
这是我的代码:
var games = await _context.Game
.Where(x => x.IsPublished == isPublished && x.IsRPG == false && x.ShelfDate >= DateTime.Now)
.Select(x => new GameEntity
{ ... }
以下是游戏和游戏实体的模型:
public partial class Game
{
public long Id { get; set; }
public string Title { get; set; }
public DateTime ShelfDate { get; set; }
public DateTime IsPublished { get; set; }
public bool IsRPG { get; set; }
public string Description { get; set; }
}
public partial class GameEntity
{
public string Title { get; set; }
public DateTime ShelfDate { get; set; }
public DateTime IsPublished { get; set; }
public bool IsRPG { get; set; }
}
我做错了什么吗?
我没有收到任何错误。
谢谢!
把响应放在这里。
数据提供程序无法识别DateTime.Now
,需要提前设置,并且查询不会对其进行计算(假设你使用的是实体框架(。