在域驱动设计中,我遇到以下情况。在域中建模查找值
我有车型。该车辆可以是掀背式汽车,SedanCar,卡车等类型。
VehicleType存储在数据库查找表中。
问题是:
如何为域建模?
我是否模型,可以像下面这样:
public class Vehicle
{
public int VehicleId{Get;Set;}
**public int VehicleTypeId { get; set; }**
public string MakeCode { get; set; }
public string ModelCode { get; set; }
public int Power { get; set; }
public int Weight { get; set; }
public int PowerToWeight { get { return Power/Weight*100; } }
}
OR
public class Vehicle
{
public int VehicleId{Get;Set;}
**public VehicleType VehicleType { get; set; }**
public string MakeCode { get; set; }
public string ModelCode { get; set; }
public int Power { get; set; }
public int Weight { get; set; }
public int PowerToWeight { get { return Power/Weight*100; } }
}
和
public class VehicleType
{
public int VehicleTypeId{Get;Set;}
public string Description{Get;Set;}
}
如果我使用的第2方式,在什么阶段我填充VehicleType模型。
谢谢。