This is my code:
return Newsletterctx.Subscribers.Count(o => o.Validated == false && o.ValidationEmailSent == true && o.SubscriptionDateTime.AddMonths(1) < DateTime.Now);
I get this error:
LINQ to Entities does not recognize the method 'System.DateTime AddMonths(Int32)' method, and this method cannot be translated into a store expression.
You can use SqlFunctions classvar;
today = DateTime.Now; return Newsletterctx.Subscribers.Count(o => o.Validated == false && o.ValidationEmailSent == true && SqlFunctions.DateAdd("month",1,o.SubscriptionDateTime) <today);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With