Example #1
0
        public override bool Equals(object obj)
        {
            DomainObjectWithTypedId <IdT> compareTo = obj as DomainObjectWithTypedId <IdT>;

            if (ReferenceEquals(this, compareTo))
            {
                return(true);
            }

            if (compareTo == null || !GetType().Equals(compareTo.GetTypeUnproxied()))
            {
                return(false);
            }

            if (HasSameNonDefaultIdAs(compareTo))
            {
                return(true);
            }

            // Since the Ids aren't the same, both of them must be transient to
            // compare domain signatures; because if one is transient and the
            // other is a persisted entity, then they cannot be the same object.
            return(IsTransient() && compareTo.IsTransient() &&
                   HasSameObjectSignatureAs(compareTo));
        }
Example #2
0
 /// <summary>
 /// Returns true if self and the provided entity have the same Id values
 /// and the Ids are not of the default Id value
 /// </summary>
 private bool HasSameNonDefaultIdAs(DomainObjectWithTypedId <IdT> compareTo)
 {
     return(!IsTransient() &&
            !compareTo.IsTransient() &&
            Id.Equals(compareTo.Id));
 }