Beispiel #1
0
 public void UpdateActor2(Actor actor)
 {
     using (WatchDb db = new WatchDb())
     {
         db.Actors.Attach(actor);
         db.Entry(actor).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #2
0
 public void UpdateMovie(Movie movie, List <int> actorsIds)
 {
     using (WatchDb db = new WatchDb())
     {
         db.Movies.Attach(movie);
         db.Entry(movie).Collection("Actors").Load();
         movie.Actors.Clear();
         db.SaveChanges();
         foreach (int id in actorsIds)
         {
             Actor actor = db.Actors.Find(id);
             if (actor != null)
             {
                 movie.Actors.Add(actor);
             }
         }
         db.Entry(movie).State = EntityState.Modified;
         db.SaveChanges();
     }
 }