I would like to use the Iesi.Collections HashedSet class for entity collections in NHibernate. The functionality I want is that duplicate entities cannot be added. I would like entities to be considered duplicate if they share the Id (i.e. primary key) field, or, if they have Id == 0 (i.e. unsaved), then certain key properties are compared instead.
I notice that by default the HashedSet appears to define duplicates using reference equality. What do I need to change in order to get the HashedSet to define duplication according to the rules I described above? (E.g. override .Equals, override ==, etc).