Подтвердить что ты не робот

LINQ to Entities не распознает метод 'System.DateTime AddSeconds (Double)', и этот метод не может быть переведен в

Я получаю эту ошибку на

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)

Аргумент.AddSeconds в моем случае должен быть "динамическим"... Любая идея, как его решить?

4b9b3361

Ответ 1

Используйте метод EntityFunctions.AddSeconds для создания даты на стороне сервера.

 .Where(x => x.DateTimeStart > currentDateTime && 
             currentDateTime >= EntityFunctions.AddSeconds(x.DateTimeStart, x.ReminderTime))