Using Unit of Work design pattern / NHibernate Sessions in an MVVM WPF

Posted by Echiban on Stack Overflow See other posts from Stack Overflow or by Echiban
Published on 2010-04-09T02:31:57Z Indexed on 2010/04/09 2:33 UTC
Read the original article Hit count: 1111

Filed under:
|
|
|

I think I am stuck in the paralysis of analysis. Please help!

I currently have a project that

Unit of Work implementation in my case supports one NHibernate session at a time. I thought at the time that this makes sense; it hides inner workings of NHibernate session from ViewModel.

Now, according to Oren Eini (Ayende): http://msdn.microsoft.com/en-us/magazine/ee819139.aspx

He convinces the audience that NHibernate sessions should be created / disposed when the view associated with the presenter / viewmodel is disposed. He presents issues why you don't want one session per windows app, nor do you want a session to be created / disposed per transaction. This unfortunately poses a problem because my UI can easily have 10+ view/viewmodels present in an app. He is presenting using a MVP strategy, but does his advice translate to MVVM?

Does this mean that I should scrap the unit of work and have viewmodel create NHibernate sessions directly? Should a WPF app only have one working session at a time? If that is true, when should I create / dispose a NHibernate session?

And I still haven't considered how NHibernate Stateless sessions fit into all this! My brain is going to explode. Please help!

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about mvvm