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 = (
from files in _fileuploadRepository.Table
join product in _productRepository.Table on files.Event equals product.Id
where
(
product.EventDate != null &&
(product.EventDate.Subtract(DateTime.Now).Days <= 60 && product.EventDate.Subtract(DateTime.Now).Days >= 60) ||
(product.EventDate.Subtract(DateTime.Now).Days <= 30 && product.EventDate.Subtract(DateTime.Now).Days >= 30) ||
(product.EventDate.Subtract(DateTime.Now).Days <= 20 && product.EventDate.Subtract(DateTime.Now).Days >= 20))
&&
files.IsSkiped == false
select files;
).ToList();
But a error occurred this query.
I am clueless. Please Help.
product.EventDate.Subtract(DateTime.Now)
. In C# an alternative notation isproduct.EventDate - DateTime.Now
where one uses an overload of the minus (-
) operator. Does anyone know if that will work with LINQ to SQL? After all, subtraction of dates is also possible in SQL dialects.