Gib*_*boK 20 linq linq-to-entities entity-framework entity-framework-4
我收到此错误
base {System.SystemException} = {"LINQ to Entities does not recognize the method 'System.DateTime AddSeconds(Double)' method, and this method cannot be translated into a store expression."}
Run Code Online (Sandbox Code Playgroud)
在这个代码上
var eventToPushCustom = eventCustomRepository.FindAllEventsCustomByUniqueStudentReference(userDevice.UniqueStudentReference)
.Where(x => x.DateTimeStart > currentDateTime && currentDateTime >= x.DateTimeStart.AddSeconds(x.ReminderTime))
.Select(y => new EventPushNotification
{
Id = y.EventId,
EventTitle = y.EventTitle,
DateTimeStart = y.DateTimeStart,
DateTimeEnd = y.DateTimeEnd,
Location = y.Location,
Description = y.Description,
DeviceToken = y.UsersDevice.DeviceTokenNotification
});
Run Code Online (Sandbox Code Playgroud)
我相信问题在于 x.DateTimeStart.AddSeconds(x.ReminderTime)
在我的情况下.AddSeconds的参数必须是"动态的"...任何想法如何解决它?
Ser*_*kiy 38
使用EntityFunctions.AddSeconds方法在服务器端创建日期时间.
.Where(x => x.DateTimeStart > currentDateTime &&
currentDateTime >= EntityFunctions.AddSeconds(x.DateTimeStart, x.ReminderTime))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10083 次 |
| 最近记录: |