views:

26

answers:

1

Hi,

I'm using NHibernate here with C#. I have a cache of nhibernate objects that have lazily loaded objects inside of those that might have changes written to them. I need a way to determine if there are changes that need to be saved. It's quite a lot of effort to set flags when one little thing changes and also quite annoying to compare a cache with a copy of an original (because of the lazy loading).

Just wondering if there's a way I can use the current session object to know if it has pending changes that are about to be written to the db, this is so that I can have a 'do you want to save' prompt if in fact there are changes. I can't autosave, the customer demands a save button.

+2  A: 

NHibernate.ISession exposes an IsDirty() method so you should be able to check that.

Lester
Thanks,That's what I'm looking for. It's reading dirty without me changing anything (that I know of) so I've got some debugging to do. Ah the nhibernate journey continues. Thanks!
IsaacB