예제 #1
0
        public virtual bool Equals(Entity other)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }
            if (ReferenceEquals(other, this))
            {
                return(true);
            }

            var thisId  = Id;
            var otherId = other.Id;

            //If both objects aren't transient and ids are same, they are equal only if the type are the same
            if (!IsTransient(this) && !IsTransient(other) && Equals(thisId, otherId))
            {
                var thisType  = GetUnproxiedType();
                var otherType = other.GetUnproxiedType();
                //If they are same type they are equal since Ids are identicay for non-transient objects.
                //  If using incompatible types, e.g. using Equals(DerivedB, DerivedA), IsAssignableFrom will return false.
                return(thisType.IsAssignableFrom(otherType) ||
                       otherType.IsAssignableFrom(thisType));
            }
            return(false);
        }
예제 #2
0
파일: Entity.cs 프로젝트: HolySquad/noname
        public virtual bool Equals(Entity other)
        {
            if (ReferenceEquals(other, null))
                return false;
            if (ReferenceEquals(other, this))
                return true;

            var thisId = Id;
            var otherId = other.Id;

            if (!IsTransient(this) && !IsTransient(other) && Equals(thisId, otherId))
            {
                var thisType = GetUnproxiedType();
                var otherType = other.GetUnproxiedType();
                return thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType);
            }
            return false;
        }
예제 #3
0
        public virtual bool Equals(Entity <TId> 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);
        }
예제 #4
0
        public virtual bool Equals(Entity other)
        {
            if (ReferenceEquals(other, null))
                return false;
            if (ReferenceEquals(other, this))
                return true;

            var thisId = Id;
            var otherId = other.Id;

            //If both objects aren't transient and ids are same, they are equal only if the type are the same
            if (!IsTransient(this) && !IsTransient(other) && Equals(thisId, otherId))
            {
                var thisType = GetUnproxiedType();
                var otherType = other.GetUnproxiedType();
                //If they are same type they are equal since Ids are identicay for non-transient objects.
                //  If using incompatible types, e.g. using Equals(DerivedB, DerivedA), IsAssignableFrom will return false.
                return thisType.IsAssignableFrom(otherType) ||
                       otherType.IsAssignableFrom(thisType);
            }
            return false;
        }