NHibernateSession.CurrentFor(factoryKey).Transaction.Begin(); try { //application logic here NHibernateSession.CurrentFor(factoryKey).Transaction.Commit(); } catch { NHibernateSession.CurrentFor(factoryKey).Transaction.Rollback(); }
[Transaction] public void DoTransaction() { //do some work here }
[Transaction] public void DoTransaction() { //do some work here DoInnerPortion(); } [Transaction] public void DoInnerPortion() { //do some more work here }
[Transaction] public void DoTransaction() { //do some work here if (someCondition) { //force rollback throw new AbortTransactionException(); } }