DbArithmeticExpression arguments must have a numeric common type

  • Error
System.ArgumentException: DbArithmeticExpression arguments must have a numeric common type.
  • Code caused the exception
ctx.Incidents
   .Where(x => (DateTime.Now - x.Time).Days == 0)
   .OrderByDescending(d => d.Time)
   .Take(50)
   .ToList();
  • Solution:
ctx.Incidents
   .Where(x => DbFunctions.DiffDays(DateTime.Now ,x.Time) == 0)
   .OrderByDescending(d => d.Time)
   .Take(50)
   .ToList();