コード例 #1
0
        public override IEnumerable <Movie> All()
        {
            // the skips the join on profile and alternative title and populates manually
            // to avoid repeatedly deserializing the same profile / movie
            var builder = new SqlBuilder()
                          .LeftJoin <Movie, MovieFile>((m, f) => m.MovieFileId == f.Id);

            var profiles = _profileRepository.All().ToDictionary(x => x.Id);
            var titles   = _alternativeTitleRepository.All()
                           .GroupBy(x => x.MovieId)
                           .ToDictionary(x => x.Key, y => y.ToList());

            return(_database.QueryJoined <Movie, MovieFile>(
                       builder,
                       (movie, file) =>
            {
                movie.MovieFile = file;
                movie.Profile = profiles[movie.ProfileId];

                if (titles.TryGetValue(movie.Id, out var altTitles))
                {
                    movie.AlternativeTitles = altTitles;
                }

                return movie;
            }));
        }
コード例 #2
0
 public List <AlternativeTitle> GetAllTitles()
 {
     return(_titleRepo.All().ToList());
 }
コード例 #3
0
 public List <AlternativeTitle> GetAllTitlesForMovie(Movie movie)
 {
     return(_titleRepo.All().ToList());
 }