Ayende wrote a great article for MSDN where he uses a session per presenter, which is kept open. Check it out: http://msdn.microsoft.com/en-us/magazine/ee819139.aspx
Diego On Tue, Dec 15, 2009 at 23:39, Broken Pipe <[email protected]>wrote: > I have a winForms app with MVP pattern, and i don't how to use > Nhibernate with lazy loading in this pattern. Currently I'm using > eager fetching with LOTS of left joins. > > So for example how manage ISession with lazy loading in classic MVP > situation when you have app showing list (DataGridVIew) of > BuisnessObjects and a Form to add\edit this BuisnessObject? > > In my current implementation i'm doing something like this: > > in my Model: > public IList<BuisnessObject> BuisnessObjectGetAll() > { > using (ISession ses = SessionFactory.OpenSession()) > { > IQuery query = ses.CreateQuery("from BuisnessObject as > obj"); > return query.List<BuisnessObject>(); > } > } > > In my BuisnessObjectList Presenter: > View.Items = Model.BuisnessObjectGetAll(); > > and in my View implementation i bind Items to DataGridView > > As you may guess with lazy loading a get lots of exceptions because > ISession is closed after i return Objects from my Model. So i want to > know how to manage ISession in this situation? > > -- > > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > > -- 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.
