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); }