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

You could use the EntityFunctions.DiffDays method

EntityFunctions.DiffDays(product.EventDate, DateTime.Now) //this will return the difference in days

UPDATE

EntityFunctions is now obsolete so you should use DBFunctions instead.

System.Data.Entity.DbFunctions.DiffDays(product.EventDate, DateTime.Now)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)