I am trying to determine the number of days between 2 dates using LINQ with Entity Framework. It is telling me that it does not recognize Subtract on the System.TimeSpan class
Here is my where portion of the LINQ query.
where ((DateTime.Now.Subtract(vid.CreatedDate).TotalDays < maxAgeInDays))
Here is the error I receive in the VS.NET debugger
{"LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)' method, and this method cannot be translated into a store expression."}
Am I doing something wrong or is there a better way to get the number of days between 2 DateTimes in the entity framework?
thanks
Michael
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…