EF的条件中,无法用转格式,时间差作为条件,这时在EF6中,可以用

DbFunctions 这个类,例如:

db.NewsComments.Any( (entity.PostDate -  p.PostDate).TotalMinutes < 30 ); //本意是找到与该数据30分钟之内的数据,但是会报错

db.NewsComments.Any( DbFunctions.DiffMinutes(entity.PostDate, p.PostDate) < 30 ); //用DbFunctions就可以得到期望结果了

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-01-22
  • 2021-06-19
  • 2021-12-23
  • 2022-12-23
  • 2022-01-20
猜你喜欢
  • 2021-12-13
相关资源
相似解决方案