If you are using Rhino-Tools - or would consider using it - there is a lot of work in there for the UnitOfWork pattern. Specifically review the LongConversationManager.cs and the UnitOfWork.cs files. These allow you to have multiple concurrent conversations going for the same user, which can be very useful in ajax settings.
On Thu, Jan 15, 2009 at 6:59 AM, Tuna Toksöz <[email protected]> wrote: > Check Fabios blog at http://fabiomaulo.blogspot.com > > > Tuna Toksöz > http://tunatoksoz.com > > Typos included to enhance the readers attention! > > > > > On Thu, Jan 15, 2009 at 12:28 PM, Stuart Campbell < > [email protected]> wrote: > >> What's the recommended way to support nested transactions in NH? >> >> Basically, I'm using session-per-request and my repository methods wrap >> all calls in a transaction like this... >> >> var tran = session.BeginTransaction(); >> try >> { >> // do work here >> >> tran.Commit(); >> } >> catch >> { >> tran.Rollback(); >> throw; >> } >> >> But I also want multiple repository calls to be contained in a logical >> "business" transaction, like this (note that all repositories expose >> BeginTransaction which returns an ITransaction wrapper): >> >> var outerTran = accountRepository.BeginTransaction(); >> try >> { >> accountRepository.Save(account); >> >> notificationRepository.Save(notification); >> >> outerTran.Commit(); >> } >> catch >> { >> outerTran.Rollback(); >> throw; >> } >> >> This doesn't work because outerTran reports that it has been committed as >> soon as the first Save() operation commits. I'm obviously missing something >> fundamental here and would be grateful if someone could point me in the >> right direction. >> >> If I have some time today I'll try looking through the NH code to try and >> understand the internals better. In the meantime any pointers would be >> welcome. >> >> thanks >> >> Stu >> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
