We use a modified version of NHibernate, and I'm trying to get back to 
using an official release (either by finding the "proper" way to do things, 
or by getting our changes into the main codebase).

We have found it helpful to have read-only access to the ActionQueue's list 
of insertions, updates and deletes. 

We use a flush event listener to intercept the flush, and then iterate over 
the objects about to be inserted/updated/deleted.

Any insertions/updates that implement an interface we have defined, 
IValidator, get validated. Likewise any deletions that implement 
IDeleteValidator have their deletion validated. 

In the event that this validation fails, we throw an exception and nothing 
is saved to the database - this makes it easy for us to ensure that 
everything in the database is in a consistent state. (We are careful to 
ensure that the validation doesn't change any objects as they might be 
missed in the flush).

The code we've added to ActionQueue is 

        public IEnumerable<object> Insertions
        {
            get { return insertions.OfType<EntityInsertAction>().Select(x 
=> x.Instance); }
        }

        public IEnumerable<object> Updates
        {
            get { return updates.Select(x => x.Instance); }
        }

        public IEnumerable<object> Deletions
        {
            get { return deletions.Select(x => x.Instance); }
        }

Is this likely to be accepted? If so I'll make a pull request 

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to