コード例 #1
0
        public override bool Equals(object rhs)
        {
            BusinessBase <T> other = rhs as BusinessBase <T>;

            if (other == null)
            {
                return(false);
            }

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

            if (!IsTransient(this) && !IsTransient(other) && Id.Equals(other.Id))
            {
                var otherType = other.GetUnproxiedType();
                var thisType  = GetUnproxiedType();
                return(thisType.IsAssignableFrom(otherType) ||
                       otherType.IsAssignableFrom(thisType));
            }
            return(false);
        }
コード例 #2
0
 /// <summary>
 /// Checks if an object is transient i.e an object yet to be associated with nHibernate proxy.
 /// An object is transient if, Id has default value. i.e. 0.
 /// </summary>
 /// <param name="obj">object for which the check is made.</param>
 /// <returns>true if transient object, else false.</returns>
 private static bool IsTransient(BusinessBase <T> obj)
 {
     return(obj != null && Equals(obj.Id, default(T)));
 }
コード例 #3
0
 /// <summary>
 /// Transient objects are not associated with an
 /// item already in storage.  For instance, a
 /// Customer is transient if its ID is 0.
 /// </summary>
 public virtual bool IsTransient()
 {
     return(BusinessBase <T> .IsTransient(this));
 }