예제 #1
0
        private static void AddObject()
        {
            BookEntities ctx     = new BookEntities();
            Film         NewFilm = new Film();

            NewFilm.Title       = "New film";
            NewFilm.Description = "New film";
            NewFilm.Length      = 300;
            FilmShowing NewFilmShowing = new FilmShowing();

            NewFilmShowing.Screen      = 5;
            NewFilmShowing.ShowingDate = System.DateTime.Now;
            NewFilm.FilmShowings.Add(NewFilmShowing);
            ctx.AddObject("Films", NewFilm);
            ctx.SaveChanges();


            //Another option
            //BookEntities ctx = new BookEntities();
            //Film NewFilm = Film.CreateFilm(0);
            //NewFilm.Title = "New film2";
            //NewFilm.Description = "New film";
            //NewFilm.Length = 300;
            //ctx.AddToFilms(NewFilm);
            //ctx.SaveChanges();
        }
예제 #2
0
        private static void Updating()
        {
            BookEntities ctx          = new BookEntities();
            Film         FilmToUpdate = ctx.Films.Where("it.FilmID = 3").First();

            FilmToUpdate.Title = "New updated title";
            ctx.SaveChanges();
        }