NHibernate TooManyRowsAffectedException when trying to delete multiple objects

Basically I get this exception when trying to delete a collection of objects with nHibernate. Below is my code

   public void DeleteAll<T>(IList<T> entities)
   {
      using(var tx = session.BeginTransaction())
      { 
        try
        {
             entities.ForEach(e=>session.Delete(e));
             tx.Commit(); 
        }
        catch(Exception)
        {
             tx.Rollback();
        }
      }
   }

Using hql works without any problems, but I would prefer to stick with the LINQish approach. Oh, and I'm connecting to an Oracle database.

+5
source share
1 answer

You cannot remove the foreach element, try and be careful with the for index, after removing the installation index -

+1
source

All Articles