public virtual void Delete(T entity) { if (IsStatelessSession) { if (!StatelessSession.IsOpen) { throw new HibernateException("The stateless NHibernate session must be open before an entity can be deleted."); } if (StatelessSession.Transaction == null) { throw new HibernateException("Deletes must be done within an NHibernate transaction."); } StatelessSession.BeginTransaction(); StatelessSession.Delete(entity); StatelessSession.Transaction.Commit(); } else { if (!Session.IsOpen) { throw new HibernateException("NHibernate session must be open before an entity can be deleted."); } if (Session.Transaction == null) { throw new HibernateException("Deletes must be done within an NHibernate transaction."); } Session.BeginTransaction(); Session.Delete(entity); Session.Transaction.Commit(); } }