LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)' method

后端 未结 4 463
野性不改
野性不改 2020-12-03 06:44

I try to select records in database in 60 days 30 days 20 days differents in current date.

Please see this query in below.

 var uploads = (
                  


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 07:00

    This should work:

    using System.Data.Entity.SqlServer;
    
    where (int)SqlFunctions.DateDiff("day", product.EventDate, DateTime.Now) <= 60
    

提交回复
热议问题