1
MVC的新手,并在多个模型具有相同属性时寻找最佳实践。例如,我有几个模型具有地址字段(地址,城市,州和邮政编码)。假设我有这些领域的客户模型和供应商模型。创建模型的最佳方式是什么?我开始与第一例子有:创建具有相同属性的数据模型的最佳做法
public class Customer
{
public int Id { get; set; }
public string AccountNumber { get; set; }
public string Customer { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public string MainPhone { get; set; }
public string fax { get; set; }
public string ContactPhone { get; set; }
}
public class Supplier
{
public int Id { get; set; }
public string AccountNumber { get; set; }
public string Supplier { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public string MainPhone { get; set; }
public string fax { get; set; }
public string ContactPhone { get; set; }
}
或交替:
public class Customer
{
public int Id { get; set; }
public string AccountNumber { get; set; }
public string Customer { get; set; }
public Address CustomerAddress { get; set; }
public Phone MainPhone { get; set; }
public Phone fax { get; set; }
public Phone ContactPhone { get; set; }
}
public class Supplier
{
public int Id { get; set; }
public string AccountNumber { get; set; }
public string Supplier { get; set; }
public Address SupplierAddress { get; set; }
public Phone MainPhone { get; set; }
public Phone fax { get; set; }
public Phone ContactPhone { get; set; }
}
public class Address
{
public string AddressLine1 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
}
public class Phone
{
public int AreaCode { get; set; }
public int NPA { get; set; }
public int Station { get; set; }
}
什么被认为是最好的做法是非常赞赏
谢谢你的回答! – Don 2015-03-25 22:58:47