public void Delete(TEntity entityToDelete)
 {
     if (_context.Entry(entityToDelete).State == EntityState.Detached)
     {
         _dbSet.Attach(entityToDelete);
     }
     _dbSet.Remove(entityToDelete);
 }
Example #2
0
 protected void DeleteEntity(EntityType entity)
 {
     if (_dbContext.Entry(entity).State == EntityState.Detached)
     {
         _dbContext.Set <EntityType>().Attach(entity);
     }
     _dbContext.Set <EntityType>().Remove(entity);
 }