2013-01-29 14 views
15

मैं इस कोड परLINQ विधि 'System.DateTime AddSeconds (डबल)' विधि को नहीं पहचानता है, और इस विधि अनुवाद नहीं किया जा सकता

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)

का तर्क है। मेरे मामले में अजीब सेकेंड "गतिशील" होना चाहिए ... कोई विचार यह कैसे हल करें?

उत्तर

30

सर्वर पक्ष पर दिनांक समय बनाने के लिए EntityFunctions.AddSeconds विधि का उपयोग करें।

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

ध्यान दें कि EntityFunctions अब अप्रचलित है। इसके बजाए 'डीबीफंक्शन' का प्रयोग करें। –

+0

@TylerForsythe अद्यतन के लिए धन्यवाद! यह एक तेजी से बदलती दुनिया है :) –

+0

{"फंक्शन डीबी। एडमिनेट्स मौजूद नहीं है"} :( –

संबंधित मुद्दे