public List <EpisodeHistory> GetBySeason(int seriesId, int seasonNumber, EpisodeHistoryEventType?eventType) { SortBuilder <EpisodeHistory> query = Query .Join <EpisodeHistory, Episode>(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id) .Join <EpisodeHistory, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id) .Where(h => h.SeriesId == seriesId) .AndWhere(h => h.Episode.SeasonNumber == seasonNumber); if (eventType.HasValue) { query.AndWhere(h => h.EventType == eventType); } query.OrderByDescending(h => h.Date); return(query); }
public static Movie FirstWithYear(this SortBuilder <Movie> query, int?year) { return(year.HasValue ? query.AndWhere(movie => movie.Year == year || movie.SecondaryYear == year).FirstOrDefault() : query.FirstOrDefault()); }