/// ------------------------------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------------------------------ public new virtual bool Equals(object obj) { AbstractDomainObject <TId> compareTo = obj as AbstractDomainObject <TId>; return((compareTo != null) && (HasSameNonDefaultIdAs(compareTo) || // Since the Ids aren't the same, either of them must be transient to // compare business value signatures (((IsTransient()) || compareTo.IsTransient()) && HasSameBusinessSignatureAs(compareTo)))); }
/// ------------------------------------------------------------------------------------------------------------ /// <summary> /// Returns true if self and the provided persistent object have the same Id values /// and the Ids are not of the default Id value /// </summary> /// ------------------------------------------------------------------------------------------------------------ private bool HasSameNonDefaultIdAs(AbstractDomainObject <TId> compareTo) { return((Id != null && !Id.Equals(default(TId))) && (compareTo.Id != null && !compareTo.Id.Equals(default(TId))) && Id.Equals(compareTo.Id)); }
/// ------------------------------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------------------------------ private bool HasSameBusinessSignatureAs(AbstractDomainObject <TId> compareTo) { return(this.GetHashCode().Equals(compareTo.GetHashCode())); }