Reputation: 256
I have a requirement to find all records using EntityFramework via LINQ where the date stored in the database is almost expired. If the date in the database is almost 2 years old then it is expired (2 years - 90 days). We want users to be notified at 90 days prior to 2 years.
My users table has DateStamp column with the date. Thus the entity has a DateStamp property. I'm not sure how to construct the LINQ to determine if the date is 2 years - 90 days or not.
from u in Users where u.DateStamp.....what's next?
Upvotes: 0
Views: 792
Reputation: 481
You can use temp DateTime variable
DateTime temp = DateTime.Now.AddYears(-2).AddDays(90);
var users = (from u in Users where u.DateStamp <= temp select u);
Upvotes: 1