Nels_P_Olsen wrote:
In trying to follow best practices, all our entities implement Object.Equals for business-meaning equality. So, foolishly I thought I should start using Object.Equals rather than == (Object.ReferenceEquals) when comparing entities. All it ended up doing is masking problems where I had duplicate entities with the same key, which cause a NonUniqueObjectException when you try to save the duplicate instance that the current session didn't fetch.
What use is Object.Equals for entities? If it ever returns true when == returns false, you're already screwed because you'll get NonUniqueObjectException, unless you're working completely detached from a session (no objects need further lazy loading or saving).
GetHashCode is probably more what you are after, using ID to help calculate the code. McCafferty has more details on one approach:
http://devlicio.us/blogs/billy_mccaffer ... ively.aspx
Hope that helps.