Due to an old codebase and how some data was set up, I found myself repeating the following LINQ statement in several places. I decided to factor it out into it's own property member of the class and use that in the .Where() calls.


private static Predicate<FeeCode> ActiveFeeCodeFilter
{
    get
    {
        return  f => (f.DateEnd > DateTime.Now || f.DateEnd == null)
            && f.DateStart < DateTime.Now;
    }
}
            

public static IEnumerable<FeeCode> GetAllActiveFeeCodes()
{
    return FeeCodes
            .OrderBy(f => f.Name)
            .Where(f => ActiveFilter(f));
}