public void Guardar(Registro reg) { try { using (var ctx = new TextContext()) { if (reg.id > 0) { ctx.Entry(reg).State = EntityState.Modified; } else { ctx.Entry(reg).State = EntityState.Added; } ctx.SaveChanges(); } } catch (Exception e) { throw; } }
public void Eliminar(int id) { try { using (var ctx = new TextContext()) { ctx.Entry(new Registro { id = id }).State = EntityState.Deleted; ctx.SaveChanges(); } } catch (Exception) { throw; } }