我向我的实体添加了一个新表并创建了一个关联。我的新代码如下。
正如您所看到的,所有以前添加的表都只是通过 get/set 进入的,该表已作为 collection 进入,在我的 razor 视图中,我不能再执行以下操作了。我怎样才能把结果放到这个视图中?
谢谢
不再工作的剃刀 @Html.DisplayFor(modelItem => item.NetInfo.Username)
错误
'System.Collections.Generic.ICollection<ITAPP.Models.tblNetworkInfo>' does not contain a definition for 'Username' and no extension method 'Username' accepting a first argument of type 'System.Collections.Generic.ICollection<ITAPP.Models.tblNetworkInfo>' could be found (are you missing a using directive or an assembly reference?)
类公共部分类 tblEquipment { public tblEquipment() { this.NetInfo = new HashSet(); }
public int ID { get; set; }
public Nullable<int> UserID { get; set; }
public Nullable<int> PreviousUserID { get; set; }
public Nullable<int> ChangeID { get; set; }
public Nullable<int> RequestedBy { get; set; }
public string MachineName { get; set; }
public bool Stock { get; set; }
public string Vendor { get; set; }
public string Model { get; set; }
public string Supplier { get; set; }
public virtual tblUser User { get; set; }
public virtual tblChangeLog ChangeLog { get; set; }
public virtual tblAssetType AssetType { get; set; }
public virtual ICollection<tblNetworkInfo> NetInfo { get; set; }