Force query execution without flush/commit

后端 未结 5 1181
太阳男子
太阳男子 2021-02-09 15:59

Hi i am using the transaction-per-request (session-in-view) pattern for an asp.net web application. I have a couple of points in the application where i want to Save an NHiberna

5条回答
  •  萌比男神i
    2021-02-09 16:47

    maybe I don't understand but can't you do it like so...

    using(var tx = session.BeginTransaction())
    {
        session.Save(entity);
        session.Flush();
    
        //perform non NH operations with entity.id
    
        tx.Commit();
    }//uncommitted transaction would be rolled back on dispose()
    

提交回复
热议问题