0
我剛開始學習MVC。所以,這裏是我的模型類爲什麼我的模型屬性未反映在剃鬚刀的自動生成視圖中? (MVC 4)
public class Patient : iPatient, iPerson
{
public string name { get; set; }
public int age { get; set; }
public DateTime dateOfBirth { get; set; }
public Address address { get; set; }
public string bloodGroup { get; set; }
}
所以,當我在控制我的操作方法,右鍵單擊並添加視圖,腳手架會產生一些像這樣的觀點:
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.name)
</th>
<th>
@Html.DisplayNameFor(model => model.age)
</th>
<th>
@Html.DisplayNameFor(model => model.dateOfBirth)
</th>
<th>
@Html.DisplayNameFor(model => model.bloodGroup)
</th>
<th></th>
</tr>
它不會產生像@Html.DisplayNameFor(model=>model.Address.City)
。
這是爲什麼?
我是否需要在視圖中手動添加它,或者是否有任何解決方法?
在此先感謝您的回答。
+1用於提示部分視圖。謝謝,但我仍然困惑爲什麼自動腳手架將不會做任何與子對象類型。] –
我認爲腳手架使用T4模板來生成視圖,檢查到這些模板可能會揭示更多的事情發生,雖然我似乎無法找到那些關於這些atm的信息或鏈接。 –