public bool Update(T entity) { try { entity.UpdateTime = DateTime.Now; table.Attach(entity); _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public async Task <T> UpdateAsync(T entity) { _context.Entry(entity).CurrentValues.SetValues(entity); await _context.SaveChangesAsync(); return(entity); }
public virtual T Update(T entity, bool save = true) { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(entity); }