Note that there are some explanatory texts on larger screens.

plurals
  1. POLinq to XML holding relationship
    primarykey
    data
    text
    <p>I have XML document with this structure:</p> <pre><code>&lt;dipOrders&gt; &lt;interchangeInfo senderEdiCode="LSC58" senderEdiCodeQal="ZZ" receiverEdiCode="15274" receiverEdiCodeQal="ZZ" syntax="X12" syntaxId="X" syntaxVersion="003010"/&gt; &lt;order orderNumber="219299" orderDate="2012-12-05T00:00:00" validityDate="2012-12-05T00:00:00"&gt; &lt;buyer name="LEAR MTO"&gt; &lt;partyCode buyerCode="811567924"/&gt; &lt;/buyer&gt; &lt;supplier name="BRIDGE OF WEIR LEATHER CO"&gt; &lt;partyCode buyerCode="749630"/&gt; &lt;/supplier&gt; &lt;orderConsignee name="LEAR MEXICAN SEATING CORP"&gt; &lt;partyCode buyerCode="LSC59"/&gt; &lt;orderLine description="LEA DC 378 HERO 6RSB 5B8" orderNumber="246767" engineeringChangeNumber="N"&gt; &lt;partyCode buyerCode="DC378105H6RSB5B8AA"/&gt; &lt;cumulativeQuantity date="2012-12-04T00:00:00" quantity="0"/&gt; &lt;orderQuantity quantity="0" commitmentLevel="Firm" timingQualifier="Weekly" shipDate="2012-12-05T00:00:00"/&gt; &lt;/orderLine&gt; &lt;orderLine description="LEA DC 378 HERO 6RSB 5V0" orderNumber="246767" engineeringChangeNumber="N"&gt; &lt;partyCode buyerCode="DC378105H6RSB5V0AA"/&gt; &lt;cumulativeQuantity date="2012-12-04T00:00:00" quantity="0"/&gt; &lt;orderQuantity quantity="0" commitmentLevel="Firm" timingQualifier="Weekly" shipDate="2012-12-05T00:00:00"/&gt; &lt;orderQuantity quantity="600" commitmentLevel="Firm" timingQualifier="Weekly" shipDate="2012-12-06T00:00:00"/&gt; &lt;/orderLine&gt; </code></pre> <p>This is how I access attributes of orderLine item:</p> <pre><code>List&lt;int&gt; orderNumbers = doc.Descendants("orderLine").Select(x =&gt; int)x.Attribute("orderNumber")).ToList(); List&lt;string&gt; descriptions = doc.Descendants("orderLine").Select(x =&gt; (string)x.Attribute("description")).ToList(); List&lt;string&gt; buyerCodes = doc.Descendants("orderLine").Select(x =&gt; (string)x.Element("partyCode").Attribute("buyerCode")).ToList(); </code></pre> <p>However, orderLine can have different number of orderQuantity nodes. How can I address it in the Linq statement to get the appropriate relationship between orderLine and orderQuantity?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload