Nested
Boolean nested = DataRelation.Nested; DataRelation.Nested = nested;
Determines whether the XML output for this DataSet
uses nesting for this relationship. If true
, the
XML elements that represent child rows appear inside the XML element
that represents the corresponding parent row. For more information on
XML and nesting rows, refer to Chapter 17.
The following example displays the XML for a
DataSet,
both with and without nesting:
DataColumn parentCol = ds.Tables["Categories"].Columns["CategoryID"]; DataColumn childCol = ds.Tables["Products"].Columns["CategoryID"]; DataRelation dr = new DataRelation("Cat_Prod", parentCol, childCol); ds.Relations.Add(dr); // Write output without nesting. ds.WriteXml(Console.Out); // Writer output with nesting. dr.Nested = true; ds.WriteXml(Console.Out);
Without nesting, the XML output has this structure:
<?xml version="1.0" standalone="yes"?> <Northwind> <Categories /> <Categories /> ... <Products /> <Products /> ... </Northwind>
With nesting, the XML output has this form:
<?xml version="1.0" standalone="yes"?> <Northwind> <Categories> <Products /> </Categories> <Categories> <Products /> </Categories> ... </Northwind>
For more information about the XML representation of a
DataSet
, refer to Chapter 17.