3

Lately I have had about enough of creating ViewModel boilerplate code, so I ended up adding the NotifyPropertyChanged-functionality to a DynamicProxy-based solution.

In order to have all of WPF's Changenotification mechanisms working for my implementation, all I have to do now is exchange my Collections with ObservableCollections, which unfortunately brings along a performance issue (change notification for every record added / removed, so not fit for bulk usage because UI gets way too busy trying to keep up with the list of changes).

Thus, In my models, collections of other models (HasMany relationships, that is) are not held within a list, but within a ObservableCollection-derivate that has two Methods SuspendCollectionChangeNotification and ResumeCollectionChangeNotification (A bit like the implementation shown here).

The infrastructure is all there, now I'm looking for an Interceptor hook that enables me to call Suspend() before NHibernate Loads Child data and Resume() after it's done.

I'm a bit afraid I will end up adding this to the proxy I mentioned above, which has a good grasp of the properties that are being requested, but it would be just lovely to keep this in an NHibernate Interceptor...

Community
  • 1
  • 1
Sebastian Edelmeier
  • 4,095
  • 3
  • 39
  • 60

1 Answers1

0

NHibernate has IInitializeCollectionEventListener which gives you InitializeCollectionEvent when it is loading a collection.

You can hook up like this:

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

Unfortunately this only tells you that collection loading is taking place. I don't think it is possible to determine when it is starting and when it has finished.

mattk
  • 1,335
  • 1
  • 14
  • 19
  • Sorry, I haven't been able to check this yet (holiday madness) I hope the SO bounty mechanism will allow me to do this once I'm back in the office – Sebastian Edelmeier Dec 24 '12 at 13:20