public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == System.Data.Entity.EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public async Task EditAsync(T model, bool saved = true) { _db.Configuration.ValidateOnSaveEnabled = false; _db.Entry(model).State = EntityState.Modified; if (saved) { await _db.SaveChangesAsync(); _db.Configuration.ValidateOnSaveEnabled = true; } }