Reputation: 47597
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.
Upvotes: 1
Views: 1448
Reputation: 47597
This helped...
using (var session = _sessionFactory.OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
session.Delete(model);
session.Flush();
tx.Commit();
}
}
Upvotes: 0
Reputation: 56934
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.
Upvotes: 5