views:

47

answers:

1

Hello,

My application consists of two views, list and detail.

Basically when user double-clicks a row from a list, I pass selected item object to detail view.

Every instance of view has it's own NHibernate session.

When user modifies object properties, my list view needs to reflect changes, to do this I implemented INotifyPropertyChanged interface.

When I try to save changes from details view I get "Illegal attempt to associate a collection with two open sessions". I know what this exception means and I know why it happens.

What would be best way/pattern to avoid this problem, so that data binding works fine and NHibernate is happy as well.

Thank You very much!

+2  A: 

This is what we use for update notifications between sessions: http://github.com/ayende/Effectus/blob/master/Effectus/Infrastructure/EventPublisher.cs

You should never share persistent objects between sessions. Pass Ids instead.

Diego Mijelshon
This helped, thanks!
Daniil Harik