次の方法で共有


2.2.6.5.5 Links

Links represent unidirectional associations or one direction of a bidirectional association between EntityTypes. Using the Customer and Order EntityTypes, associations, and instance sample data, as described in Appendix A: Sample Entity Data Model and CSDL Document (section 6), the set of links from the Customer with EntityKey "ALFKI" to Order instances are represented by a set of URIs, with each URI in the set identifying a single Order that is linked to the Customer. Such link information MUST be serialized as an XML document that conforms to the XML schema [XMLSCHEMA1/2] shown in the following XML Schema for a Set of Links Represented Using XML listing. In the serialization, one URI element MUST exist for each link, with the text value of the element equal to the canonical URI of the linked-to EntityType instance. Additionally, the target namespace MAY be server-specific, as described in Common Serialization Rules for XML-based Formats (section 2.2.6.1).

 <?xml version="1.0" encoding="utf-8"?>
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             targetNamespace="http://schemas.microsoft.com/ado/2007/08/dataservices">
   <xsd:element name="links">
     <xsd:complexType mixed="false">
       <xsd:sequence>
         <xsd:element name="uri" type="xsd:string" minOccurs="0"
                      maxOccurs="unbounded"/>
       </xsd:sequence>
     </xsd:complexType>
   </xsd:element>
 </xsd:schema>

Listing: XML Schema for a Set of Links Represented Using XML

A single link, which is not part of a set, MUST be serialized as an XML document that conforms to the XML schema [XMLSCHEMA1/2] shown in following XML Schema for a Single Link Represented Using XML listing. The definition of the URI element in this case is unchanged from above. The targetNamespace in the XSD MAY be server-specific, as described in Common Serialization Rules for XML-based Formats (section 2.2.6.1).

 <?xml version="1.0" encoding="utf-8"?>
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             targetNamespace="http://schemas.microsoft.com/ado/2007/08/dataservices">
    <xsd:element name="uri" type="xsd:string" minOccurs="1"
                 maxOccurs="1"/>
 </xsd:schema>

Listing: XML Schema for a Single Link Represented Using XML

For example, using the sample model and instance data, as described in Appendix A: Sample Entity Data Model and CSDL Document (section 6), the links from the Customer with EntityKey entity "ALFKI" to Order instances are represented as follows.

 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <links xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
   <uri>http://host/service.svc/Orders(1)</uri>
   <uri>http://host/service.svc/Orders(2)</uri>
 </links>

Listing: Example of Links Formatted as XML