コード例 #1
0
        /// <summary>
        /// Returns true if ProductReview instances are equal
        /// </summary>
        /// <param name="other">Instance of ProductReview to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ProductReview other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProductReviewID == other.ProductReviewID ||
                     ProductReviewID != null &&
                     ProductReviewID.Equals(other.ProductReviewID)
                     ) &&
                 (
                     ProductId == other.ProductId ||
                     ProductId != null &&
                     ProductId.Equals(other.ProductId)
                 ) &&
                 (
                     ReviewerName == other.ReviewerName ||
                     ReviewerName != null &&
                     ReviewerName.Equals(other.ReviewerName)
                 ) &&
                 (
                     ReviewDate == other.ReviewDate ||
                     ReviewDate != null &&
                     ReviewDate.Equals(other.ReviewDate)
                 ) &&
                 (
                     EmailAddress == other.EmailAddress ||
                     EmailAddress != null &&
                     EmailAddress.Equals(other.EmailAddress)
                 ) &&
                 (
                     Rating == other.Rating ||
                     Rating != null &&
                     Rating.Equals(other.Rating)
                 ) &&
                 (
                     Comments == other.Comments ||
                     Comments != null &&
                     Comments.Equals(other.Comments)
                 ));
        }
コード例 #2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (ProductReviewID != null)
         {
             hashCode = hashCode * 59 + ProductReviewID.GetHashCode();
         }
         if (ProductId != null)
         {
             hashCode = hashCode * 59 + ProductId.GetHashCode();
         }
         if (ReviewerName != null)
         {
             hashCode = hashCode * 59 + ReviewerName.GetHashCode();
         }
         if (ReviewDate != null)
         {
             hashCode = hashCode * 59 + ReviewDate.GetHashCode();
         }
         if (EmailAddress != null)
         {
             hashCode = hashCode * 59 + EmailAddress.GetHashCode();
         }
         if (Rating != null)
         {
             hashCode = hashCode * 59 + Rating.GetHashCode();
         }
         if (Comments != null)
         {
             hashCode = hashCode * 59 + Comments.GetHashCode();
         }
         return(hashCode);
     }
 }