[英]how to get data from multiple model in mvc4?
我在應用程序的自定義視圖中上傳圖像時遇到問題,我有三種模型
public int EmpId { get; set; }
public string EmployeeName { get; set; }
public virtual ICollection<Picture> picture{ get; set; }
第二
public int MacId { get; set; }
public string machine { get; set; }
第三
public int PicId { get; set; }
public string PicPath { get; set; }
public int MacId { get; set; }
public int EmpId { get; set; }
public virtual Employee Employee { get; set; }
我想讓它顯示mac的圖片,誰拿走它呢?
使用要綁定到視圖的必要屬性創建新模型。
例如:
class newModelName
{
public Model1TypeName model1 {get ; set; }
public Model2TypeName model2 {get ; set; }
public Model3TypeName model3 {get ; set; }
}
現在,您可以將此新模型綁定到視圖,該視圖將具有來自所有三個視圖的所有必要信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.