예제 #1
0
 public static void Delete(int?id)
 {
     using (dbpeliculasEntities db = new dbpeliculasEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 tblPelicula pelicula = db.tblPelicula.Find(id);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
예제 #2
0
 public static void Update(tblPelicula pelicula)
 {
     using (dbpeliculasEntities db = new dbpeliculasEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.tblPelicula.Attach(pelicula);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }