LINQ to Entities does not recognize the method 'System.DateTime AddSeconds(Double)' method, and this method cannot be translated into
Use EntityFunctions.AddSeconds method to create date time on server side.
.Where(x => x.DateTimeStart > currentDateTime &&
currentDateTime >= EntityFunctions.AddSeconds(x.DateTimeStart, x.ReminderTime))
Related videos on Youtube
![GibboK](https://i.stack.imgur.com/Labo5.png?s=256&g=1)
GibboK
A professional and enthusiastic Senior Front End Developer. Listed as top 2 users by reputation in Czech Republic on Stack Overflow. Latest open source projects Animatelo - Porting to JavaScript Web Animations API of Animate.css (430+ stars on GitHub) Industrial UI - Simple, modular UI Components for Shop Floor Applications Frontend Boilerplate - An opinionated boilerplate which helps you build fast, robust, and adaptable single-page application in React Keyframes Tool - Command line tool which convert CSS Animations to JavaScript objects gibbok.coding📧gmail.com
Updated on June 14, 2022Comments
-
GibboK about 2 years
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?
-
Tyler Forsythe about 10 yearsNote that EntityFunctions is now obsolete. Use
DbFunctions
instead. -
Sergey Berezovskiy about 10 years@TylerForsythe thanks for update! It's a fast-changing world :)
-
Pažout over 9 years{"FUNCTION db.AddMinutes does not exist"} :(
-
Sergey Berezovskiy over 9 years@Pažout are you using MySQL database?
-
Shaiju T almost 9 years@ Tyler Forsythe ,which version of entity framework is needed for using
DbFunctions
?