title: Create DataTables from XSD with Complex Types defined in multiple XSD files in C# .net 4
body: <p>I have a bunch of XSD's from <a href="https://github.com/XeroAPI/XeroAPI-Schemas/tree/master/v2.00" rel="nofollow">https://github.com/XeroAPI/XeroAPI-Schemas/tree/master/v2.00</a></p>
  
  <p>I need to do two things:</p>
  
  <ol>
  <li>Create tables for each type, my first one is for Contact in Contact.xsd.</li>
  <li>When the table is populated then I need to get the XML back out of the table so it can be sent as a REST request.</li>
  </ol>
  
  <p>I can't get past item 1 :(</p>
  
  <p>I've marked all these XSD's as embedded resources in my .net C# project</p>
  
  <p>I'm then using reflection to load the XSD using the DataSet.ReadXmlSchema(ContactXsdStream) but this XSD references types specified in BaseTypes.xsd and it throws an error "Undefined complexType 'DataContractBase' is used as a base for complex type extension".</p>
  
  <pre><code>var assembly = Assembly.GetExecutingAssembly();
  var dataset = new DataSet();
  var manifestResourceStream = assembly.GetManifestResourceStream(schemaName);
  if (manifestResourceStream == null)
    throw new FileNotFoundException(string.Format("Unable to find schema resource {0}", schemaName));
  
  using (var textStreamReader = new StreamReader(manifestResourceStream))
  {
    dataset.ReadXmlSchema(textStreamReader);
    textStreamReader.Close();
  }
  return dataset;
  </code></pre>
  
  <p>All help is appreciated </p>
  
  <h2>Additional Considerations</h2>
  
  <p>I understand that there is not a contact complex type does not directly map to as a single table, however I may need to embed the complex types such as Address as an XML string in the data table.</p>
  
  <p>The reason I need simple types is that the DataTables are passed to a Data Synchronisation API (Simego DataSync Studio).  This sync tool allows me to two way sync to CRM, SharePoint, Excel and other datasource.  I will use other sync frameworks if more appropriate any other recommendations welcome.</p>
  
  <p>Kind regards
  Si</p>