using System; using System.Linq.Expressions; namespace Sample { public class NullableDateTimePredicates { public static Expression, bool>> HasDateValue() { return f => f.HasValue; } public static Expression, bool>> GreaterThan( DateTime dateToCompareWith ) { return f => f.HasValue && f.Value > dateToCompareWith; } public static Expression, bool>> LessThan(DateTime dateToCompareWith) { return f => f.HasValue && f.Value < dateToCompareWith; } public static Expression, bool>> Equals(DateTime dateToCompareWith) { return f => f.HasValue && f.Value == dateToCompareWith; } } }