We have an entity with DateTime property DateDestroyed
. A query needs to return results where this value is between nullable DateTimes startDate
and endDate
.
The where clauses I have are:
.Where(x => startDate.HasValue ? startDate <= x.DateDestroyed : true)
.Where(x => endDate.HasValue ? x.DateDestroyed <= endDate : true);
The query always return no results. I'm pretty sure I haven't written this query properly but don't know how it should be written or why it's not working?