【发布时间】:2017-06-18 14:18:21
【问题描述】:
我正在尝试在网上商店项目中创建购买历史,我希望历史类从购物车中获取产品,我从未做过多对一的关系(我认为最适合情况),你怎么看?
public class Clothes
{
[Key]
public int Id { get; set; }
public ClothesType Type { get; set; }
public int Amount { get; set; }
[Range(10, 150)]
public double Price { get; set; }
public string ImagePath { get; set; }
public virtual History historyID { get; set; }
}
public class History
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int historyID { get; set; }
public string Email { get; set; }
public string Address { get; set; }
public string City { get; set; }
public DateTime ShipDate { get; set; }
public int Price { get; set; }
public virtual ICollection<Clothes> HistClothes { get; set; }
}
【问题讨论】:
-
您的命名似乎令人困惑。一个
History(那是什么)有很多“衣服”?一个具有复数名称的类似乎很奇怪......
标签: c# asp.net model-view-controller asp.net-mvc-5 webshop