LINQ to Entities with AddMonth method

后端 未结 4 798
渐次进展
渐次进展 2020-12-05 17:18

This is my code:

 return Newsletterctx.Subscribers.Count(o =>
     o.Validated == false &&
     o.ValidationEmailSent == true &&
     o.Su         


        
4条回答
  •  無奈伤痛
    2020-12-05 17:52

    Now, EntityFramework, Version=6 above, you can jus use System.Data.Entity.DbFunctions

    return Newsletterctx.Subscribers.Count(o =>
     o.Validated == false &&
     o.ValidationEmailSent == true &&
      DbFunctions.AddMonths(o.SubscriptionDateTime,1) < DateTime.Now);
    

    However, in this case, use the temp variable testDate that answered by Fredrik Mörk uses less resources.

提交回复
热议问题