views:

36

answers:

1

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.

+4  A: 

Perhaps you can shift the date to test against instead:

DateTime testDate = DateTime.Now.AddMonths(-1);
return Newsletterctx.Subscribers.Count
            (o => o.Validated == false 
             && o.ValidationEmailSent == true 
             && o.SubscriptionDateTime < testDate);
Fredrik Mörk