共用方式為


AssociationSet Element (EntityContainer CSDL)

In the Entity Data Model (EDM), the AssociationSet element in conceptual schema definition language (CSDL) specifies an association in the class that will be built from the conceptual schema.

The object model that will be built from the conceptual schema requires both programmable classes and storage structures to contain data for applications built on the model. An AssociationSetMapping in mapping specification language (MSL) connects the AssociationSet defined in CSDL to the AssociationSet in SSDL describing the storage structures.

The following CSDL syntax shows the declaration of an AssociationSet named Employee_Employee_ManagerID. This AssociationSet is part of the EntityContainer named HumanResources. Although this EntityContainer is defined in the AdventureWorksHRModel schema, the EntityContainer is an independent element. The AssociationSet element assigns a Name and identifies the AssociationType of the association used in this set designation.

When the programming object model is built, entities of the Employee_Employee_ManagerID type can be instantiated in application code. For completeness, the declaration of the AssociationType is included after the EntityContainer and AssociationSet.

  <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>

See Also

Concepts

AssociationSet Element (EntityContainer SSDL)
EntitySetMapping Element (MSL)
Entity Sets (EDM)
Association Sets (EDM)
ReferentialConstraint Element (Association CSDL)