예제 #1
0
 //Metodo eliminar
 public void Eliminar()
 {
     try
     {
         using (var db = new Model_Entity_1())
         {
             db.Entry(this).State = EntityState.Deleted;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #2
0
 //Metodo guardar
 public void Guardar()
 {
     try
     {
         using (var db = new Model_Entity_1())
         {
             if (this.categoria_id > 0)//cuando la llave primaria es identity solamante
             {
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex) {
         throw;
     }
 }