Specifica di relazioni tra elementi senza alcun annidamentoSpecify Relations Between Elements with No Nesting

Se gli elementi non sono annidati, non viene creata alcuna relazione implicita.When elements are not nested, no implicit relations are created. Tuttavia, è possibile specificare esplicitamente relazioni tra gli elementi non annidati mediante il msdata: Relationship annotazione.You can, however, explicitly specify relations between elements that are not nested by using the msdata:Relationship annotation.

Nell'esempio seguente viene illustrato un XML Schema in cui il msdata: Relationship annotazione viene specificata tra la ordine e OrderDetail elementi, che non sono annidati.The following example shows an XML Schema in which the msdata:Relationship annotation is specified between the Order and OrderDetail elements, which are not nested. Il msdata: Relationship annotazione viene specificata come elemento figlio del Schema elemento.The msdata:Relationship annotation is specified as the child element of the Schema element.

<xs:schema id="MyDataSet" xmlns=""   
             xmlns:xs="http://www.w3.org/2001/XMLSchema"   
             xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">  
 <xs:element name="MyDataSet" msdata:IsDataSet="true">  
  <xs:complexType>  
    <xs:choice maxOccurs="unbounded">  
      <xs:element name="OrderDetail">  
       <xs:complexType>  
         <xs:sequence>  
           <xs:element name="OrderNo" type="xs:string" />  
           <xs:element name="ItemNo" type="xs:string" />  
         </xs:sequence>  
       </xs:complexType>  
      </xs:element>  
      <xs:element name="Order">  
       <xs:complexType>  
         <xs:sequence>  
           <xs:element name="OrderNumber" type="xs:string" />  
           <xs:element name="EmpNumber" type="xs:string" />  
         </xs:sequence>  
       </xs:complexType>  
      </xs:element>  
    </xs:choice>  
  </xs:complexType>  

  </xs:element>  
   <xs:annotation>  
     <xs:appinfo>  
       <msdata:Relationship name="OrdOrderDetailRelation"  
                            msdata:parent="Order"   
                            msdata:child="OrderDetail"   
                            msdata:parentkey="OrderNumber"   
                            msdata:childkey="OrderNo"/>  
     </xs:appinfo>  
  </xs:annotation>  
</xs:schema>  

Il processo di mapping dello schema di XML Schema definition language (XSD) crea un DataSet con ordine e OrderDetail tabelle e una relazione specificata tra le due tabelle, come illustrato di seguito.The XML Schema definition language (XSD) schema mapping process creates a DataSet with Order and OrderDetail tables and a relationship specified between these two tables, as shown below.

RelationName: OrdOrderDetailRelation  
ParentTable: Order  
ParentColumns: OrderNumber   
ChildTable: OrderDetail  
ChildColumns: OrderNo   
Nested: False  

Vedere ancheSee Also

Generazione di relazioni tra DataSet da XML Schema (XSD)Generating DataSet Relations from XML Schema (XSD)
Mapping tra vincoli XML Schema (XSD) e vincoli di DataSetMapping XML Schema (XSD) Constraints to DataSet Constraints
Provider gestiti ADO.NET e Centro per sviluppatori di set di datiADO.NET Managed Providers and DataSet Developer Center