我有一个从我的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