AssociationSet 元素 (EntityContainer CSDL)

在 实体数据模型 (EDM) 中,概念性架构定义语言 (CSDL) 中的 AssociationSet 元素指定将从概念性架构生成的类中的关联。

从概念性架构生成的对象模型要求可编程类和存储结构包含在模型上生成的应用程序的数据。映射规范语言 (MSL) 中的 AssociationSetMapping 将 CSDL 中定义的 AssociationSet 连接到描述存储结构的 SSDL 中的 AssociationSet

下面的 CSDL 语法显示名为 Employee_Employee_ManagerIDAssociationSet 的声明。此 AssociationSet 是名为 HumanResourcesEntityContainer 的一部分。虽然此 EntityContainerAdventureWorksHRModel 架构中进行了定义,但 EntityContainer 仍是一个独立的元素。AssociationSet 元素指定一个 Name,并标识该集指定中使用的关联的 AssociationType

编程对象模型生成后,可以在应用程序代码中对 Employee_Employee_ManagerID 类型的实体进行实例化。出于完整性考虑,将 AssociationType 的声明放在了 EntityContainerAssociationSet 的后面。

  <EntityContainer Name="HumanResources">
    <AssociationSet Name="Employee_Employee_ManagerID" Association="
                 AdventureWorksHRModel.Employee_Employee_ManagerID">
      <End Role="Employee" EntitySet="Employee" />
      <End Role="EmployeeManager" EntitySet="Employee" />
    </AssociationSet>
  </EntityContainer>
  <Association Name="FK_Employee_Employee_ManagerID">
    <End Role="Employee" Type="Self.Employee" Multiplicity="0..1" />
    <End Role="Employee63" Type="Self.Employee" Multiplicity="*" />
  </Association>

另请参见

概念

AssociationSet 元素 (EntityContainer SSDL)
EntitySetMapping 元素 (MSL)
实体集 (EDM)
关联集 (EDM)