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