Hi, How can I write the linq query to check DateOfBirth is between given date.
A:
var IsBetween = (from p in People
where p.DateOfBirth.HasValue
&& lowDate <= p.DateOfBirth.Value
&& p.DateOfBirth.Value <= highDate
select true).FirstOrDefault();
-or -
var IsBetween =
People.Where(p => p.DateOfBirth.HasValue)
.Select(p => p.DateOfBirth.Value)
.Any(date => lowDate <= date && date <= highDate);
Do you want the search limited to just one person?
James Curran
2010-08-31 14:40:45