Chris Klepeis
Chris Klepeis

Reputation: 9973

WPF, Nhibernate v2 Session Persistence

I have a WPF application that loads modules into my application via prism / MEF. Each module will reference an assembly I created to house NHibernate functionality (Unit of Work & repository pattern). Now that I started on the first module, the following questions came up:

It's my understanding that the session is lightweight, so opening and closing a session is not a problem... however, if I close the session then I lose the change tracking... when I call Save, and the object is the same as when it was retrieve, I do not want a query to be executed.

Upvotes: 0

Views: 319

Answers (1)

Vadim
Vadim

Reputation: 17957

  1. Do not have the session open for a the lifetime of a wpf/windows application. You will have performance and memory problems if you do.

  2. It really depends how these modules interact. Are they separate systems, or do they need to work in tandem to do work. If it's the former, I would say that they shouldn't share sessions. If it's the latter, I would use some kind of session manager that can pass out the current session.

Upvotes: 2

Related Questions