Questo è il mio codice:LINQ to Entities con metodo AddMonth
return Newsletterctx.Subscribers.Count(o =>
o.Validated == false &&
o.ValidationEmailSent == true &&
o.SubscriptionDateTime.AddMonths(1) < DateTime.Now);
ottengo questo errore:
LINQ to Entities does not recognize the method 'System.DateTime AddMonths(Int32)' method, and this method cannot be translated into a store expression.
In questo caso, genera un'eccezione durante la dichiarazione della variabile testDate: System.NullReferenceException: 'Riferimento oggetto non impostato su un'istanza di un oggetto.' CS $ <> 8__locals0 era nullo. –
@ İlkinElimov Sì, se la sequenza contiene riferimenti null, ciò potrebbe accadere. Puoi correggerlo filtrandoli prima con '.Subscribers.Where (o => o! = Null) .Count (o => ...' –