Dies ist mein Code:LINQ to Entities mit AddMonth Methode
return Newsletterctx.Subscribers.Count(o =>
o.Validated == false &&
o.ValidationEmailSent == true &&
o.SubscriptionDateTime.AddMonths(1) < DateTime.Now);
ich diesen Fehler:
LINQ to Entities does not recognize the method 'System.DateTime AddMonths(Int32)' method, and this method cannot be translated into a store expression.
In diesem Fall wirft ihn Ausnahme bei der Deklaration Testdate Variable: System.NullReferenceException: ‚Objektverweis nicht auf eine Instanz eines Objekts festgelegt.‘ CS $ <> 8__locals0 war null. –
@ İlkinElimov Ja, wenn die Sequenz Nullreferenzen enthält, kann das passieren. Sie können das beheben, indem Sie sie zuerst mit '. Subscribers aussortieren. Wo (o => o! = Null) .Count (o => ...' –