Converting an XML schema to a DataSet is very easy under .NET.
However, the DataSets that I get after the conversion is done are
rather messy.
The problem is that the schema is organized into sections, and for
every enclosing tag .NET creates a runt table with nothing in it but
an auto-generated ID and a link to the parent table.
While I do get all of the tables I want, I also get a dozen other
spurious tables like the one I described.
I've tried messing with IsDataSet="false" and looking for examples on
the Web and in this group, but almost all of the examples show
IsDataSet="true". When I change it to "false" for any of the enclosing
tags (for which I don't want tables generated), .NET decides to
produce no tables for those tags or any tags that they enclose.
Does anyone know what IsDataSet="false" was meant to do? Does anyone
know how to get rid of those annoying extra tables that clutter up the
DataSets?
Here is an example.
<schema id="cod"
xmlns:de="dataExport"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
targetNamespace="dataExport"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<element name="exportedData" >
<complexType>
<sequence>
<element name="moduleInfo" type="de:moduleInfoType"/>
<element name="customers" type="de:CustomersType" />
</sequence>
</complexType>
</element>
<complexType name="moduleInfoType">
<attribute name="fullName" type="string"/>
<attribute name="companyName" type="string"/>
<attribute name="date" type="dateTime"/>
</complexType>
<complexType name="CustomersType">
<sequence>
<element name="customer" type="de:CustomerType" minOccurs="1"
maxOccurs="unbounded" />
</sequence>
</complexType>
<complexType name="CustomerType">
<attribute name="code" type="string" use="required" />
<attribute name="name" type="string"/>
</complexType>
</schema>
If I load this into .NET using the ReadXmlSchema() method, I get a
"customers" table and a "customers_Id" in the "customer" table,
neither of which is of any use. The "customers" table contains only a
"customers_Id", and, given the structure of the XML, there will only
ever be one of them.
Is there something I can add to the XML schema to instruct
ReadXmlSchema() that I don't need a "customers" table and its
associated relationship with "customer"?