private static IEnumerable <Employee> FilterDateField(KeyValuePair <string, object> filterProp, IEnumerable <Employee> employees) { var dateSearchProps = (Dictionary <string, DateTime?>)filterProp.Value; DateTime?minDate = dateSearchProps["MinDate"]; DateTime?maxDate = dateSearchProps["MaxDate"]; switch (filterProp.Key) { case "DateOfBirth": if (minDate.HasValue && SqlHelpers.IsValidSqlDate(minDate.Value)) { employees = employees.Where(l => l.DateOfBirth >= minDate); } if (maxDate.HasValue && SqlHelpers.IsValidSqlDate(maxDate.Value)) { employees = employees.Where(l => l.DateOfBirth < maxDate.Value.Date.AddDays(1)); } break; } return(employees); }