Advertisement
TankorSmash

for SO

Mar 18th, 2013
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.33 KB | None | 0 0
  1. //group movie_ids to several genre_strings
  2.    var movieID_genreString_grouping = from mtg in db.MovieToGenres
  3.                                                        join genre in db.Genres on
  4.                                                            mtg.genre_ID equals
  5.                                                            genre.genre_ID
  6.                                                        group genre.genre_string by
  7.                                                            mtg.movie_ID;
  8.  
  9.         //create the list of NITVMs
  10.         var nitvmQuery =
  11.             //left outer join so that all movies get selected even if there's no omdb match
  12.             from movie in db.Movies
  13.             join omdb in db.Omdb on
  14.                 movie.movie_ID equals omdb.movie_ID into mov_omdb_matches
  15.             from mov_omdb_match in mov_omdb_matches.DefaultIfEmpty()
  16.             //match the boxarts
  17.             from boxart in db.BoxArts
  18.             where movie.movie_ID == boxart.movie_ID
  19.             //match the genres string
  20.             from grp in movieID_genreString_grouping
  21.             where grp.Key == movie.movie_ID
  22.             //match the genre id
  23.  
  24.             //create the NITVM
  25.             select new FullViewModel
  26.                        {
  27.                            Movie = movie,
  28.                            Boxarts = boxart,
  29.                            Genres = grp,
  30.                            Genre_IDs = (List<int>)(from mtg in db.MovieToGenres
  31.                                                    where mtg.movie_ID == movie.movie_ID
  32.                                                    select mtg.genre_ID),
  33.                            //OmdbEntry = (mov_omdb_match == null) ? mov_omdb_match.movie_ID= movie.movie_ID: mov_omdb_match
  34.                            OmdbEntry = mov_omdb_match
  35.                        };
  36.  
  37.         //fill the TV Ratings for the dropdown list
  38.         //get all the tv ratings from the db
  39.         IQueryable<FullViewModel> min_tmeter_res = Tools.GetFullDbQuery(new MovieDbContext());
  40.         var all_tmeters = (from fmv in min_tmeter_res    
  41.                             where fmv.OmdbEntry.t_Meter != null
  42.                                  select fmv.OmdbEntry.t_Meter).Distinct()
  43.                                                             .OrderBy( item => item);
  44.         var array = all_tmeters.ToArray();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement