这是我的产品类别
public abstract class Product
{
public Product()
{
this.ComplementaryProducts = new HashSet<Product>();
this.RelatedProducts = new HashSet<Product>();
}
[Key]
public int serialNum { get; set; }
public double price { get; set; }
public double? discountPerCent { get; set; }
public double? discountPrice { get; set; }
public double weight { get; set; }
public string description { get; set; }
public Boolean? specialOffer { get; set; }
public Boolean? proposedBuy { get; set; }
public Boolean? firstPage { get; set; }
public Boolean? visible { get; set; }
public Boolean? deleted { get; set; }
public List<string> imgUrls { get; set; }
public DateTime? dateCreated { get; set; }
public DateTime? dateUpdated { get; set; }
public DateTime? dateDeleted { get; set; }
public ICollection<Product> ComplementaryProducts { get; set; }
public ICollection<Product> RelatedProducts { get; set; }
//this two lines i think are not exactly what i want
public List<Category> categories { get; set; }
public List<SubCategory> subCategories { get; set; }
}
这是我的类别和子类别类
public class Category
{
[Key]
public string name { get; set; }
List<SubCategory> subCategories { get; set; }
}
public class SubCategory
{
[Key]
public string name { get; set; }
}
在最后两个类中,我可以创建类别和子类别的层次结构,但是如何说产品既属于类别又属于父类别的某些子类别?