UPDATE
public T SaveOrUpdate(T entity)
{
using (Session)
{
using (TransactionScope scope = new TransactionScope())
{
Session.SaveOrUpdate(entity); scope.Complete();
}
return entity;
}
}
And this is absolutely correct... because your session FlushMode would most likely be:
session.FlushMode = FlushMode.Commit;
Pleae see more details here: Nhibernate Flush works commit doesn't
DELETE
But the poor sister
Delete()
is not fully supported as mighty Update()public void Delete(T entity)
{
using (Session)
{
this.Session.Delete(entity);
}
}
So, while even for
Delete()
the session FlushMode
is still hooked on a transaction commit ... there is no transaction. And that's for sure (well most likely) the real reason (as suspected)
Summary, treat both,
Update
and Delete
as the twins... and give them the same care - i.e. transaction
No comments:
Post a Comment
Note: only a member of this blog may post a comment.