Repeater控件具有强类型对象实体框架

时间:2018-02-27 12:29:12

标签: vb.net entity-framework

我是实体框架的新手,并想知道是否有人可以提供帮助。我有2个类定义文档,然后是它们的版本(1到多个关系)。

我使用asp:repeater来显示文档列表,但无法访问版本信息。

下面有两个班级

Public Class Document
  <Key>
  Public Property ID As Guid
  Public Property Name As String
  Public Property Description As String
  Public Property CreationDate As Date
  Public Property ReviewDate As Date
  Public Property NextReview As Date
  Public Overridable Property Versions As ICollection(Of DocumentVersion)
End Class

Public Class DocumentVersion
  <Key>
  Public Property VersionID As Guid
  <ForeignKey("Document")>
  Public Property DocumentID As Guid
  Public Property FilePath As String
  Public Property CreationDate As Date
  Public Overridable Property Document As Document
End Class

在asp:repeater中,我使用<%#: Item.Name %>来显示文档名称,但不能访问<%#: Item.Versions.FilePath %>

如果我包含item.versions.filepath我得到错误: BC30456:'FilePath'不是'ICollection(Of DocumentVersion)'的成员。

非常感谢任何帮助。

0 个答案:

没有答案