在我的应用程序中,我使用的是实体框架.
我的表
-Article
-period
-startDate
Run Code Online (Sandbox Code Playgroud)
我需要匹配=>的记录 DateTime.Now > startDate and (startDate + period) > DateTime.Now
我试过这个代码,但现在正在运行
Context.Article
.Where(p => p.StartDate < DateTime.Now)
.Where(p => p.StartDate.AddDays(p.Period) > DateTime.Now)
Run Code Online (Sandbox Code Playgroud)
当我运行我的代码时,会发生以下异常
LINQ to Entities无法识别方法'System.DateTime AddDays(Double)'方法,并且此方法无法转换为商店表达式.