nhibernate

NHibernate delete operation


What are possible reasons why NHibernate does not perform delete operation?

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

I tried to call session.Clear() method, that didn't help either. I'm kind a confused. :/

MyType in this case has only Id&Name. Creating operation works successfully.


Solution

  • Flush the session, or put the Delete in a Transaction and commit the Transaction.

    NHibernate will - by default - try to postpone the execution of SQL Statements as much as possible.