///<summary> /// Returns a value indicating whether this instance is equal to a specified object. ///</summary> ///<param name="toObject">An object to compare to this instance.</param> ///<returns>true if toObject is a <see cref="AlphabeticalListOfProductsBase"/> and has the same value as this instance; otherwise, false.</returns> public virtual bool Equals(AlphabeticalListOfProductsBase toObject) { if (toObject == null) return false; return Equals(this, toObject); }
///<summary> /// Determines whether the specified <see cref="AlphabeticalListOfProductsBase"/> instances are considered equal. ///</summary> ///<param name="Object1">The first <see cref="AlphabeticalListOfProductsBase"/> to compare.</param> ///<param name="Object2">The second <see cref="AlphabeticalListOfProductsBase"/> to compare. </param> ///<returns>true if Object1 is the same instance as Object2 or if both are null references or if objA.Equals(objB) returns true; otherwise, false.</returns> public static bool Equals(AlphabeticalListOfProductsBase Object1, AlphabeticalListOfProductsBase Object2) { // both are null if (Object1 == null && Object2 == null) return true; // one or the other is null, but not both if (Object1 == null ^ Object2 == null) return false; bool equal = true; if (Object1.ProductId != Object2.ProductId) equal = false; if (Object1.ProductName != Object2.ProductName) equal = false; if (Object1.SupplierId != null && Object2.SupplierId != null ) { if (Object1.SupplierId != Object2.SupplierId) equal = false; } else if (Object1.SupplierId == null ^ Object1.SupplierId == null ) { equal = false; } if (Object1.CategoryId != null && Object2.CategoryId != null ) { if (Object1.CategoryId != Object2.CategoryId) equal = false; } else if (Object1.CategoryId == null ^ Object1.CategoryId == null ) { equal = false; } if (Object1.QuantityPerUnit != null && Object2.QuantityPerUnit != null ) { if (Object1.QuantityPerUnit != Object2.QuantityPerUnit) equal = false; } else if (Object1.QuantityPerUnit == null ^ Object1.QuantityPerUnit == null ) { equal = false; } if (Object1.UnitPrice != null && Object2.UnitPrice != null ) { if (Object1.UnitPrice != Object2.UnitPrice) equal = false; } else if (Object1.UnitPrice == null ^ Object1.UnitPrice == null ) { equal = false; } if (Object1.UnitsInStock != null && Object2.UnitsInStock != null ) { if (Object1.UnitsInStock != Object2.UnitsInStock) equal = false; } else if (Object1.UnitsInStock == null ^ Object1.UnitsInStock == null ) { equal = false; } if (Object1.UnitsOnOrder != null && Object2.UnitsOnOrder != null ) { if (Object1.UnitsOnOrder != Object2.UnitsOnOrder) equal = false; } else if (Object1.UnitsOnOrder == null ^ Object1.UnitsOnOrder == null ) { equal = false; } if (Object1.ReorderLevel != null && Object2.ReorderLevel != null ) { if (Object1.ReorderLevel != Object2.ReorderLevel) equal = false; } else if (Object1.ReorderLevel == null ^ Object1.ReorderLevel == null ) { equal = false; } if (Object1.Discontinued != Object2.Discontinued) equal = false; if (Object1.CategoryName != Object2.CategoryName) equal = false; return equal; }