2013-01-29 19 views
15

bu koduLINQ yöntemi 'System.DateTime AddSeconds (Çift)' yöntemini tanımıyor ve

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."} 

bu hatayı almaya içine bu yöntem tercüme edilemez

 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 
            }); 

Sorunun x.DateTimeStart.AddSeconds(x.ReminderTime)

içinde olduğuna inanıyorum. Benim durumumdaki .AddSeconds argümanı "dinamik" olmalıdır ... Herhangi bir fikir nasıl çözülür?

cevap

30

Kullanım EntityFunctions.AddSeconds yöntem sunucu tarafında tarih zaman yaratmak.

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

EntityFunctions artık geçersiz olduğunu unutmayın. Bunun yerine 'DbFunctions' kullanın. –

+0

@TylerForsythe Güncelleme için teşekkürler! Bu bir hızla değişen dünya :) –

+0

{ "İŞLEVİ db.AddMinutes yok"} :(Pažout @ –

İlgili konular