I receive this error on
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."}
on this code
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
});
I believe the problem is in x.DateTimeStart.AddSeconds(x.ReminderTime)
The argument of .AddSeconds in my case must be "dynamic" ... Any idea how to solve it?
Use EntityFunctions.AddSeconds method to create date time on server side.
.Where(x => x.DateTimeStart > currentDateTime &&
currentDateTime >= EntityFunctions.AddSeconds(x.DateTimeStart, x.ReminderTime))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With