NHibernate interceptor / hook for Lazy-Loaded / Cascade collections

I've had enough of creating a ViewModel template lately, so I've included the NotifyPropertyChanged functionality in the DynamicProxy solution.

For all WPF Changenotification mechanisms to work for my implementation, all I have to do is exchange my collections with ObservableCollections, which unfortunately lead to a performance issue (change notification for each record added / removed, so not suitable for bulk use because the UI is too busy trying to keep up with the changelog).

So in my models, collections of other models (HasMany relations, that is) are not stored in a list, but inside an ObservableCollection-derived which has two methods SuspendCollectionChangeNotification

and ResumeCollectionChangeNotification

(a bit like the implementation shown here ).

The infrastructure is all there, now I am looking for an interceptor hook that allows me to call Suspend()

before NHibernate loads the Child data and Resume()

after it completes.

I'm a little scared, I'll add this to the proxy I mentioned above, which is good at understanding the properties that are being requested, but it would be fine to keep that in the NHibernate Interceptor ...

+3


source to share


1 answer


NHibernate has IInitializeCollectionEventListener

which gives you InitializeCollectionEvent

when loading the collection.

You can connect like this:



var listener = new YourCollectionListenerImpl();
configuration.SetListener(ListenerType.LoadCollection, adapter);

      

Unfortunately, this only says that the build is in progress. I don't think it is possible to determine when it will start and when it will end.

0


source







All Articles