if both of them are transient instances the referenceequals is ok, if they are not transient Id value is not the default for the type, then you should do equality by id only.
Gustavo. On Wed, Feb 4, 2009 at 8:25 AM, Stefan Sedich <[email protected]>wrote: > > Hello, > > I have an equals override like so: > > public virtual bool Equals(DomainObject<TKey> obj) > { > if (ReferenceEquals(null, obj)) return false; > if (ReferenceEquals(this, obj)) return true; > if (GetType() != obj.GetType()) return false; > return obj.Id.Equals(Id); > } > > public override bool Equals(object obj) > { > if (ReferenceEquals(null, obj)) return false; > if (ReferenceEquals(this, obj)) return true; > if (GetType() != obj.GetType()) return false; > return Equals((DomainObject<TKey>)obj); > } > > > Now my question is that say I have a Person and a Proxied version of a > person both with the same ID Equals will evaluate to false, as they > are not the same type. Now will this cause issues with NH > or am I ok to keep using this equals method? > > > > Cheers > Stefan > > -- > Stefan Sedich > Software Developer > http://weblogs.asp.net/stefansedich > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
