예제 #1
0
        /// <summary>
        /// Equals the specified other.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns>bool.</returns>
        public virtual bool Equals(BaseDeletableModel <TKey> other)
        {
            if (other == null)
            {
                return(false);
            }

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

            if (IsTransient(this) || IsTransient(other) || !Equals(this.Id, other.Id))
            {
                return(false);
            }

            var otherType = other.GetUnproxiedType();
            var thisType  = this.GetUnproxiedType();

            return(thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType));
        }
예제 #2
0
 /// <summary>
 /// Determines whether the specified object is transient.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <returns>
 ///   <c>true</c> if the specified object is transient; otherwise, <c>false</c>.
 /// </returns>
 private static bool IsTransient(BaseDeletableModel <TKey> obj) =>
 obj != null && Equals(obj.Id, default(int));