public bool Editar(T item) { try { var entry = contexto.Entry(item); if (entry.State == EntityState.Detached) { var currentEntry = dataBase.Find(item.Id); if (currentEntry != null) { var attachedEntry = contexto.Entry(currentEntry); attachedEntry.CurrentValues.SetValues(item); item.Atualizar(contexto); } else { dataBase.Attach(item); entry.State = EntityState.Modified; } } contexto.Save(); return(true); } catch { return(false); } }
public bool Atualizar(T entity) { try { m_Context.Entry(entity).State = EntityState.Modified; //m_DbSet.Attach(entity); //((IObjectContextAdapter)m_Context).ObjectContext.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(true); } catch (Exception ex) { _erro = ex; return(false); } }
public virtual void Editar(T entidade) { db.Entry(entidade).State = EntityState.Modified; }