using ProjectBase.Utils; namespace EnterpriseSample.Core.Domain { public class Product : DomainObject<long> { /// <summary> /// Needed by ORM for reflective creation. /// </summary> private Product() { } public Product(string productName, Supplier suppliedBy) { ProductName = productName; SuppliedBy = suppliedBy; } public string ProductName { get { return productName; } set { Check.Require(!string.IsNullOrEmpty(value), "ProductName may not be null or empty"); productName = value; } } public Supplier SuppliedBy { get { return suppliedBy; } // Assume that it doesn't make sense to ever change the supplier of a product protected set { Check.Require(value != null, "SuppliedBy may not be null"); suppliedBy = value; } } /// <summary> /// Hash code should ONLY contain the "business value signature" of the object and not the ID /// </summary> public override int GetHashCode() { return (GetType().FullName + "|" + ProductName + "|" + SuppliedBy.GetHashCode()).GetHashCode(); } private string productName; private Supplier suppliedBy; } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)