天天看點

【EntityFramework CodeFirst 】錯誤解析:DbArithmeticExpression arguments must have a numeric common type.錯誤資訊:原因分析:解決辦法:

錯誤資訊:

System.ArgumentException:“DbArithmeticExpression arguments must have a numeric common type.”

原因分析:

Linq to Entity 語句 where 中使用了 (DateTime.Now - (DateTime)實體日期類型屬性).TotalDays

解決辦法:

1、替換為: DateTime.Compare((DateTime)實體日期類型屬性,DateTime.Now)

2、替換為:System.Data.Entity.DbFunctions.DiffDays(實體日期類型屬性,DateTime.Now)