public static Movie FirstWithYear(this SortBuilder <Movie> query, int?year) { return(year.HasValue ? query.FirstOrDefault(movie => movie.Year == year || movie.SecondaryYear == year) : query.FirstOrDefault()); }