From time to time you need to filter data by difference between two dates. For instance, you wanna take a difference between date from a record and Today.
Standard LINQ request will fail with the statement like the following:
var r = from e in Entity where e.Date.Subtract(DateTime.Today) <= 5;
var r = from e in Entity where EntityFunctions.DiffDays(DateTime.Today, e.Date) <= 5;
For someone who cannot use EntityFunctions for any reason there is a workaround. Long story short, you should compare the dates. The following changes might be done:
var maxDate = DateTime.Today.AddDays(5); var r = ... where e.Date <= maxDate;