NHibernate delete operation

What are the possible reasons why NHibernate is not performing the delete operation?

 public bool Delete(MyType model)
 {
     using (var session = _sessionFactory.OpenSession())
         session.Delete(model);
     return true;
 }

      

I tried calling session.Clear () method which didn't help either. I'm confused.:/

MyType in this case only has Id & Name. Operation creation completed successfully.

0


a source to share


2 answers


Drop the session or put Delete in the transaction and commit the transaction.



NHibernate will - by default - try to delay execution of SQL statements as much as possible.

+3


a source


That helped...



using (var session = _sessionFactory.OpenSession())
{
    using (ITransaction tx = session.BeginTransaction())
    {
        session.Delete(model);
        session.Flush();
        tx.Commit();
    }
}

      

0


a source







All Articles