NHibernate Custom Collections - the Clean Way
I've been converting a fairly substantial web site to NHibernate 2.1.2 (from 1.5), and during that conversion process was having some difficulties with a custom collection that had been mapped using the method explained by Billy McCafferty. Upon close inspection I found that only one method actually was doing anything different to a regular list - Add - so I wanted to find a way to do it more simply.
The first thing I thought of was using Extension methods as suggested in Billy's next post, but that doesn't work for existing methods - you can make an extension method but it will never be called if it has the same signature as an existing method. I found another post by Colin Jack which allows you to just use a I basically just made a base class called Changing from a List to a collection meant changing some unit tests that were accessing individual elements by index, but that was all set up code so it was easy enough to do that before actually adding. All in all, I think it's a really good change and will try to use this method in the future.OverridableCollection
ICollection
IList