1
對於一個.Net MVC應用程序,是不好的做法,有一個視圖模型與其中的方法填充視圖模型如此 -是不是很好的做法,有一個視圖模型與其中的方法,填補視圖模型
public class MyViewModelClass
{
public string MyProperty1 { get; set; }
public string MyProperty2 { get; set; }
public string GetProperties()
{
this.MyProperty1 = DataRetriever.GetProperty1();
this.MyProperty2 = DataRetriever.GetProperty2();
}
}
這是否會導致MVC中的問題,例如從視圖中發佈?
控制器應檢索來自模型數據。視圖模型只能用於傳輸數據。 – ZippyV
謝謝,ZippV。特別是你的答案有什麼理由嗎? –