コード例 #1
0
 public void Eliminar()
 {
     try
     {
         ListaCompraContext context = new ListaCompraContext();
         context.Entry(this).State = EntityState.Deleted;
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
 public void Save()
 {
     try
     {
         ListaCompraContext context = new ListaCompraContext();
         if (this.id > 0)
         {
             context.Entry(this).State = System.Data.Entity.EntityState.Modified;
         }
         else
         {
             context.Entry(this).State = System.Data.Entity.EntityState.Added;
         }
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }