我有一個從我的SQL數據庫中自動生成的模型。在視圖中顯示ICollection
class Organization
{
public Organization()
{
this.ContactTitles = new HashSet<ContactTitle>();
this.OrganizationAddresses = new HashSet<OrganizationAddress>();
this.OrganizationBusinessTypes = new HashSet<OrganizationBusinessType>();
this.OrganizationCountries = new HashSet<OrganizationCountry>();
this.OrganizationEmails = new HashSet<OrganizationEmail>();
this.OrganizationMemberships = new HashSet<OrganizationMembership>();
this.OrganizationNotes = new HashSet<OrganizationNote>();
this.OrganizationPhones = new HashSet<OrganizationPhone>();
this.OrganizationWebsites = new HashSet<OrganizationWebsite>();
this.Contacts = new HashSet<Contact>();
this.OrganizationIndustryCodes = new HashSet<OrganizationIndustryCode>();
}
public int OrganizationID { get; set; }
public string Name { get; set; }
public virtual ICollection<ContactTitle> ContactTitles { get; set; }
public virtual ICollection<OrganizationAddress> OrganizationAddresses { get; set; }
public virtual ICollection<OrganizationBusinessType> OrganizationBusinessTypes { get; set; }
public virtual ICollection<OrganizationCountry> OrganizationCountries { get; set; }
public virtual ICollection<OrganizationEmail> OrganizationEmails { get; set; }
public virtual ICollection<OrganizationMembership> OrganizationMemberships { get; set; }
public virtual ICollection<OrganizationNote> OrganizationNotes { get; set; }
public virtual ICollection<OrganizationPhone> OrganizationPhones { get; set; }
public virtual ICollection<OrganizationWebsite> OrganizationWebsites { get; set; }
public virtual ICollection<Contact> Contacts { get; set; }
public virtual ICollection<OrganizationIndustryCode> OrganizationIndustryCodes { get; set; }
}
在我的組織視圖中,在我的索引頁上 - 強制鍵入我的組織模型。
我想在組織索引頁上顯示我認爲應該在ICollection中的成員資格信息。除非我錯過了解釋它的作用。
當我將@Html.DisplayFor(modelItem => item.OrganizationMemberships.
抓取OrganizationMembership表中的數據時,它不會顯示在IntelliSense上。我只需要能夠顯示數據,我不必提交任何形式的更改。
我有'@model PagedList.IPagedList'來利用PagedList的東西。所以這就是爲什麼我在組織視圖上無法使用OrganizationMemberships做任何事情? Model.OrganizationMembership也不起作用 - 它聲明它不包含定義。 –
cfisher
@kifi什麼是你的視圖頂部聲明的模型類型? – McGarnagle
'@model PagedList.IPagedList' 這是在我的視圖的頂部聲明 –
cfisher