//改 public int Edit(T s) { dbContext.Set <T>().Attach(s); dbContext.Entry(s).State = EntityState.Modified; return(dbContext.SaveChanges()); }
/// <summary> /// 删除 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool DeleteEntity(T entity) { Db.Entry <T>(entity).State = (EntityState)System.Data.EntityState.Deleted; return(true); //return Db.SaveChanges() > 0; }
//U public bool Update(T entity) { dbContext.Entry(entity).State = EntityState.Modified; return(dbContext.SaveChanges() > 0); }
public bool DeleteEntity(T entity) { db.Entry <T>(entity).State = System.Data.EntityState.Deleted; return(true); }
/// <summary> /// Updates an item /// </summary> /// <param name="entity">Item to update</param> public void Update(TEntity entity) { Context.Entry(entity).State = EntityState.Modified; }
public void Update(TEntity item) { _context.Entry(item).State = EntityState.Modified; }
public void Update(T entity) { this.dbSet.Attach(entity); context.Entry(entity).State = EntityState.Modified; }