public void Eliminar() { try { using (var ctx = new TestContex()) { ctx.Entry(this).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Guardar() { try { using (var ctx = new TestContex()) { if (this.id > 0) { ctx.Entry(this).State = System.Data.Entity.EntityState.Modified; } else { ctx.Entry(this).State = System.Data.Entity.EntityState.Added; } ctx.SaveChanges(); } } catch (Exception) { throw; } }