我有以下代码片段:
var dataSet = new DataSet("Data");
var table = GetCustomerTable();
var orgTable = GetOrganizationTable();
dataSet.Tables.Add(table);
dataSet.Tables.Add(orgTable);
var relation = new DataRelation("CustomerMembership", dataSet.Tables["Customers"].Columns["CustomerId"], dataSet.Tables["Organizations"].Columns["CustomerId"])
{Nested = true};
dataSet.Relations.Add(relation);
dataSet.WriteXml(@"C:\MyFeed.xml");
这给了我以下结果:
<Customers>
<CustomerId>272408857</CustomerId>
<snip>
<Organizations>
<OrganizationName>Org1</OrganizationName>
</Organizations>
<Organizations>
<OrganizationName>Org2</OrganizationName>
</Organizations>
</Customers>
我正在寻找的是这样的:
<Customers>
<CustomerId>272408857</CustomerId>
<snip>
<Organizations>
<OrganizationName>Org1</OrganizationName>
<OrganizationName>Org2</OrganizationName>
</Organizations>
</Customers>
关于如何OrganizationName
嵌套在一个Organization
节点内的任何想法;而不是有 2 个节点,每个节点都有一个值?