views:

218

answers:

2

Hello

I am using NHibernate for a project, and I am absolutely beginner. I am fetching some objects from a table and showing it to a form, where they can be edited. If an user inserts a new object into the table from some other window, I want to show this newly inserted object into the edit window. My application uses tabbed window interface, so user can simultaneously open insert window and edit window at the same time.

So basically what I need is a way to determine if a newly created object exists in the database which is not fetched before by ISession, and if not, then fetch that new object from the database. In other words, I need to synchronize my session with the database, just like flush method, but in the reverse way.

Can anyone help me?

+4  A: 

Publish/Subscription method works well for this. Check out the Publishing Events part of Ayende's sample desktop application. Basically after you've added a new item, you publish that information and other parts of your application that subscribed can update their lists accordingly.

dotjoe
Thank you, I gained a lot of insights from that article about how NHibernate should be used
Night Shade
+2  A: 

You are taking the path to NHibernate Hell.

Be sure to work your infrastructure (ie defining interfaces, defining session management patterns and notification pattern) and isolate these non-business utilies from the rest of your code before using NHibernate to implement them.

Good luck.

Nelson
Thank you for your suggestion, Nelson. I will certainly remember your advise.....:)
Night Shade