//insert// Códigos de error virtual public bool Insertar(ref string error, tEntity item) { error = string.Empty; try { using (workspaceEntities ctx = new workspaceEntities()) { ctx.Entry(item).State = EntityState.Added; ctx.SaveChanges(); return(true); } } catch (Exception e) { error = e.Message; return(false); } }
// actualizar virtual public bool Actualizar(ref string error, tEntity item) { int result = -1; error = string.Empty; try { using (workspaceEntities ctx = new workspaceEntities()) { // puede insertar registros relacionados (no actualizarlos) ctx.Entry(item).State = EntityState.Modified; result = ctx.SaveChanges(); return(true); } } catch (Exception e) { error = e.Message; return(false); } }