예제 #1
0
        /// <summary>
        /// Equals
        /// </summary>
        /// <param name="other">other entity</param>
        /// <returns>Result</returns>
        public virtual bool Equals(BaseEntityMongo other)
        {
            if (other == null)
            {
                return(false);
            }

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

            if (!IsTransient(this) &&
                !IsTransient(other) &&
                Equals(Id, other.Id))
            {
                var otherType = other.GetUnproxiedType();
                var thisType  = GetUnproxiedType();
                return(thisType.IsAssignableFrom(otherType) ||
                       otherType.IsAssignableFrom(thisType));
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Gets or sets the entity identifier
        /// </summary>
        //public int Id { get; set; }

        /// <summary>
        /// Is transient
        /// </summary>
        /// <param name="obj">Object</param>
        /// <returns>Result</returns>
        private static bool IsTransient(BaseEntityMongo obj)
        {
            return(obj != null && Equals(obj.Id, default(int)));
        }