【发布时间】:2016-02-27 05:11:14
【问题描述】:
只是在此处寻找有关最佳做法的一些指导。我有一个产品订单系统的订单清单,如下所示:-
public class CurrentOrderManifestViewModel
{
public int OrderID { get; set; }
public List<CurrentOrderItem> CurrentOrderItems { get; set; }
public decimal? MinimumOrderSurcharge { get; set; }
public decimal? OrderSurcharge { get; set; }
}
public class CurrentOrderItem
{
public int OrderProductID { get; set; }
public string ProductDescription { get; set; }
public string ProductCode { get; set; }
public decimal? UnitPrice { get; set; }
public int Quantity { get; set; }
public decimal? VATRate { get; set; }
public decimal? VATValue { get; set; }
public decimal? GoodsValue { get; set; }
public bool IsOnPromotion { get; set; }
}
我现在处于应用程序的不同区域,与最初创建它的位置不同,我发现自己具有相同格式的非常相似的属性。但是上面所有与价格有关的字段都不会填写,因为我只是在看产品名称和描述。
我应该创建一个只包含我需要的属性的不同模型,还是使用相同的模型并在订单项列表中有很多 NULL 值?
谢谢!
【问题讨论】:
-
可以创建一个类然后让另一个扩展它,然后在每个区域使用正确的类
标签: c# asp.net-mvc model-view-controller model naming-conventions