我在
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."}
在此代码上
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
});
我相信问题出在x.DateTimeStart.AddSeconds(x.ReminderTime)
的参数。在我的情况下,添加秒必须是"动态的"......知道如何解决吗?
使用 EntityFunctions.AddSeconds 方法在服务器端创建日期时间。
.Where(x => x.DateTimeStart > currentDateTime &&
currentDateTime >= EntityFunctions.AddSeconds(x.DateTimeStart, x.ReminderTime))