Beispiel #1
0
        /// <summary>
        /// Confronto tra due oggetti (viene confrontata Primary Key)
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public override bool Equals(object other)
        {
            DataObjectBase oOther = other as DataObjectBase;

            //Se null non può essere uguale
            if (oOther == null)
            {
                return(false);
            }

            //Se sono la stessa istanza torna true
            if (object.ReferenceEquals(this, oOther))
            {
                return(true);
            }


            //Schema differenti
            if (!object.Equals(this.mClassSchema.InternalID, oOther.mClassSchema.InternalID))
            {
                return(false);
            }

            Key oPriKey = this.mClassSchema.PrimaryKey;

            //Verifica uguaglianza Primary Key
            for (int i = 0; i < this.mClassSchema.PrimaryKey.Properties.Count; i++)
            {
                if (!object.Equals(this.mClassSchema.PrimaryKey.Properties[i].GetValue(this), this.mClassSchema.PrimaryKey.Properties[i].GetValue(oOther)))
                {
                    return(false);
                }
            }

            return(true);
        }