模型IList返回null值

时间:2013-12-03 20:16:46

标签: .net asp.net-mvc asp.net-mvc-4

这是我的模特课:

public class BillOfLading{
// Tracking Number
    public string tracking_number { get; set; }
    public string current_status { get; set; }
    public int bol_user_id { get; set; }
    public IList<HazmatDesc> HazmatDesc { get; set; } 
}
public class HazmatDesc
{
    public int Id { set; get; }

    [Display(Name = "NMFC Item NO.")]
    public int? nmfc_item_no { get; set; }
    [Display(Name = "NMFC Sub")]
    public int? nmfc_sub { get; set; }
    [Required]
    [Display(Name = "Pieces")]
    public int pieces { get; set; }
    [Required]
    [Display(Name = "Package Type")]
    public string package_type { set; get; }
    [Required]
    [Display(Name = "HM")]
    public bool hm { set; get; }
    [Required]
    [Display(Name = "Description")]
    public string description_articles { set; get; }
    [Required]
    [Display(Name = "Class")]
    public string hazmat_class { set; get; }
    [Required]
    [Display(Name = "Weight(lbs.)")]
    public int hazmat_weight { set; get; }
}

}

当我通过模型保存数据时,它工作正常,HazmatDesc中的所有值都存储在数据库中,这也保存了BillOfLading模型的ID。

问题是当我试图检索BillOfLading时,HazmatDesc中没有值:

enter image description here

这是BillOfLading_ID数据库中的记录:

enter image description here

我曾尝试使用BillOfLading_ID检索Hazmatdesc,但它不起作用。

即使为模型BillOfLading HazmatDesc数据创建一个脚手架编辑模板也不存在。

无论如何要克服这一点,或者我错过了什么?

0 个答案:

没有答案