コード例 #1
0
        //public void AddMovieToDb(Movie movie)
        //{
        //    var entities = new MovieDbEntities();

        //    if (entities.Movies.Where(o => o.ImdbId.Equals(movie.ImdbId)).ToList().Count() == 0)
        //    {
        //        entities.AddToMovies(movie);
        //        entities.SaveChanges();
        //    }
        //    else
        //    {
        //        //Already exists
        //        Console.WriteLine(@"Exists: {0}", movie.ImdbId);
        //    }
        //}
        #endregion

        public void RemoveMovie(string imdbId)
        {
            _entities.DeleteObjects(_entities.MovieGenres.Where(o => o.Movie.ImdbId == imdbId));
            _entities.DeleteObjects(_entities.MovieCountries.Where(o => o.Movie.ImdbId == imdbId));
            _entities.DeleteObjects(_entities.MovieKeywords.Where(o => o.Movie.ImdbId == imdbId));
            _entities.DeleteObjects(_entities.MovieLanguages.Where(o => o.Movie.ImdbId == imdbId));
            _entities.DeleteObjects(_entities.MoviePersonalNotes.Where(o => o.Movie.ImdbId == imdbId));
            _entities.DeleteObjects(_entities.MovieUserLists.Where(o => o.Movie.ImdbId == imdbId));


            _entities.DeleteObjects(_entities.Movies.Where(o => o.ImdbId == imdbId));


            _entities.SaveChanges();
        }