XML
<wd:Report_Entry>
<wd:Cost_Center wd:Descriptor=\"8808 ECO Global Forwarding Austria\">
<wd:ID wd:type=\"WID\">b81295748006019ec87c29edcb020044</wd:ID>
<wd:ID wd:type=\"Organization_Reference_ID\">8808</wd:ID>
<wd:ID wd:type=\"Cost_Center_Reference_ID\">8808</wd:ID>
</wd:Cost_Center>
<wd:Type wd:Descriptor=\"Cost Center\">
<wd:ID wd:type=\"WID\">64d1af75258301630e215c7292024500</wd:ID>
<wd:ID wd:type=\"Organization_Type_ID\">Cost_Center</wd:ID>
</wd:Type>
<wd:Reference_ID>8808</wd:Reference_ID>
<wd:code>8808</wd:code>
<wd:name>ECO Global Forwarding Austria</wd:name>
<wd:Included_by_Organizations wd:Descriptor=\"RU7860 Europe Forwarding Overhead\">
<wd:ID wd:type=\"WID\">b8129574800601751d8538accb023f35</wd:ID>
<wd:ID wd:type=\"Organization_Reference_ID\">RU7860</wd:ID>
<wd:ID wd:type=\"Custom_Organization_Reference_ID\">RU7860</wd:ID>
</wd:Included_by_Organizations>
<wd:Availability_Date>1900-01-01T00:00:00.000-08:00</wd:Availability_Date>
<wd:Is_Organization_Active>0</wd:Is_Organization_Active>
</wd:Report_Entry>
<wd:Report_Entry>
<wd:Cost_Center wd:Descriptor=\"8810 Sales GF - Austria\">
<wd:ID wd:type=\"WID\">hello</wd:ID>
<wd:ID wd:type=\"Organization_Reference_ID\">8810</wd:ID>
<wd:ID wd:type=\"Cost_Center_Reference_ID\">8810</wd:ID>
</wd:Cost_Center>
<wd:Type wd:Descriptor=\"Cost Center\">
<wd:ID wd:type=\"WID\">6hello</wd:ID>
<wd:ID wd:type=\"Organization_Type_ID\">Cost_Center</wd:ID>
</wd:Type>
<wd:Reference_ID>8810</wd:Reference_ID>
<wd:code>8810</wd:code>
<wd:name>Sales GF - Austria</wd:name>
<wd:Included_by_Organizations wd:Descriptor=\"RU2302 Vienna Global Forwarding\">
<wd:ID wd:type=\"WID\">b8129574800601968a2e289ccb02062b</wd:ID>
<wd:ID wd:type=\"Organization_Reference_ID\">RU2302</wd:ID>
<wd:ID wd:type=\"Custom_Organization_Reference_ID\">RU2302</wd:ID>
</wd:Included_by_Organizations>
<wd:Availability_Date>1900-01-01T00:00:00.000-08:00</wd:Availability_Date>
<wd:Is_Organization_Active>0</wd:Is_Organization_Active>
</wd:Report_Entry>
Id Collection
var orgId = (from x in xml.Descendants(xmlNamespace + "Included_by_Organizations").Elements()
select x into y
where y.Attribute(xmlNamespace + "type").Value == "Organization_Reference_ID"
select y.Value);
Установка значений для свойств объекта
var costCenterValues = from cc in xml.Descendants(xmlNamespace + "Report_Entry")
select new CostCenter
{
CostCenterId = cc.Element(xmlNamespace + "Reference_ID").Value,
Name = cc.Element(xmlNamespace + "name").Value,
Code = cc.Element(xmlNamespace + "code").Value,
//CostCenterHierarchyId =
};
return costCenterValues.ToList();
Учитывая xml выше, что является лучшим способ установить значение CostCenterHierarchyID? который представляет собой идентификатор Organization_Reference_ID для коллекции Included_by_Organizations xml. Я могу получить все значения из var orgId, но я не уверен, как установить правильное значение для каждой записи в costCenterValues - CostCenterHierarchyId.
<wd:Included_by_Organizations wd:Descriptor=\"RU7860 Europe Forwarding Overhead\">
<wd:ID wd:type=\"WID\">b8129574800601751d8538accb023f35</wd:ID>
<wd:ID wd:type=\"Organization_Reference_ID\">RU7860</wd:ID>
<wd:ID wd:type=\"Custom_Organization_Reference_ID\">RU7860</wd:ID>
</wd:Included_by_Organizations>