views:

318

answers:

1

I am a newbie to Object Oriented Programming. I am working with Windows Application and Model View Presenter Pattern and I want to have the Change tracking available. My question is as follows

Do I need the presenter to hold a Nhibernate Session or Linq to Sql Datacontext for my Unit Of Work? Is this the simplest way I can architect a Winform app? If I have a complex form where there could be multiple UOW on the same form, then In the simplest way I would have a presenter for each of those UOW.

Am i correct in this way of thinking??

+1  A: 

Yes. The best approach I've found for Windows Form projects using NHibernate is to use the ISession as a unit-of-work. Therefore the scope and lifetime of the ISession is the same as your UOW. You may want to consider if your form has multiple UOWs or multiple transactions within a single UOW.

See also: Building a Desktop To-Do Application with NHibernate

Jamie Ide