Reputation: 1377
Basically I'm getting this exception while trying to delete a collection of entities 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 issue but I'd prefer to stick to the LINQish approach.. Oh and I'm connecting to an Oracle database.
Upvotes: 5
Views: 800
Reputation:
You can't delete item by foreach, try for and be careful with index of for, after remove set index --
Upvotes: 1