How can the following problem be dealt with?
We\'re using lazy loaded NHibernate properties and whenever we\'re calling Equals()
or GetHashCode()<
I use the following rules:
If entity has a POID property (remember that there is not need of property or any member just omit the name="XX", not sure if activerecord or the mapping strategy you are using supoprt this)
If entity doesn't have a POID property, for sure you will need a natural-id. Use natural id for equality and GetHashCode.
If you have a natural-id with many-to-one, instead of doing FooProperty.Equals(other.FooProperty), use FooProperty.Id.Equals(other.FooProperty.Id). Accessing the ID doesn't trigger the initialization of the lazy reference.
Last but not least, using composite-id is discourage, and composite id with key-many-to-one is very discourage.