Beispiel #1
0
        /// <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(GenericEntity <TID> compareTo)
        {
            Check.Require(compareTo != null, "compareTo may not be null");

            return((Id != null && !Id.Equals(default(TID))) &&
                   (compareTo.Id != null && !compareTo.Id.Equals(default(TID))) &&
                   Id.Equals(compareTo.Id));
        }
Beispiel #2
0
        public virtual new bool Equals(object obj)
        {
            GenericEntity <TID> compareTo = obj as GenericEntity <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))));
        }
Beispiel #3
0
        /// <summary>
        /// Must be provided to properly compare two objects
        /// </summary>
        //public virtual abstract override int GetHashCode();

        private bool HasSameBusinessSignatureAs(GenericEntity <TID> compareTo)
        {
            Check.Require(compareTo != null, "compareTo may not be null");

            return(GetHashCode().Equals(compareTo.GetHashCode()));
        }