Reputation: 55
I would like to get values between two Datetime which values between one day ago and today but I don't know how I do it.
_db.Contact.Where(p => DateTime.Now.AddDays(-1) < p.Date <= DateTime.Now && p.Email == entity.Email).ToList()
Upvotes: 0
Views: 171
Reputation: 5518
Close, but you can't chain conditions like that in C#. You need to make two separate conditions for the <
and the <=
:
_db.Contact.Where(p => DateTime.Now.AddDays(-1) < p.Date
&& p.Date <= DateTime.Now
&& p.Email == entity.Email)
.ToList()
Upvotes: 1