/// <summary>
        /// Compares the current object with another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// A 32-bit signed integer that indicates the relative order of the objects being compared.
        /// The return value has the following meanings:
        /// <list type="table">
        /// <listheader>
        /// <term>Value</term>
        /// <description>Meaning</description>
        /// </listheader>
        /// <item>
        /// <term>Less than zero</term>
        /// <description>This object is less than the <paramref name="other" /> parameter.</description>
        /// </item>
        /// <item>
        /// <term>Zero</term>
        /// <description>This object is equal to <paramref name="other" />.</description>
        /// </item>
        /// <item>
        /// <term>Greater than zero</term>
        /// <description>This object is greater than <paramref name="other" />.</description>
        /// </item>
        /// </list>
        /// </returns>
        public virtual int CompareTo(EntityWithTypedId <TId> other)
        {
            // If other is not a valid object reference, this instance is greater.
            if (other == null)
            {
                return(1);
            }

            if (IsTransient() && other.IsTransient())
            {
                return(0);
            }

            if (IsTransient())
            {
                return(-1);
            }

            if (other.IsTransient())
            {
                return(1);
            }

            return(Id.CompareTo(other.Id));
        }
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// <c>true</c> if the current object is equal to the <paramref name="other" /> parameter;
        /// otherwise, <c>false</c>.
        /// </returns>
        public virtual bool Equals(EntityWithTypedId <TId> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other == null || (GetType() != other.GetType()))
            {
                return(false);
            }

            return(Id.Equals(other.Id));
        }