Appendix B. ADO.NET XML Extensions

Appendix B. ADO.NET XML Extensions

Microsoft defines two namespaces for configuring DataSet schema files: codegen (urn:schemas-microsoft-com:xml-msprop) and msdata (urn:schemas-microsoft-com:xml-msdata). These namespaces extend the XSD format, allowing it to represent additional database-specific properties and allowing you to configure how typed DataSets are generated. In addition, the diffgr, or DiffGram namespace (urn:schemas-microsoft-com:xml-diffgram-v1), defines attributes that provide a way for XML documents to track DataSet changes and row insertions and deletions.

The structure of the XSD file for a DataSet is as follows:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="DataSetName">

  <xs:element name="DataSetName" >
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">

        <xs:element name="DataTableName" >
          <xs:complexType>
            <xs:sequence>

              <xs:element name="FieldName" />

          </xs:complexType>
        </xs:element>

      </xs:choice>
    </xs:complexType>

    <xs:unique name="ConstraintName" />
    <xs:keyref name="RelationName" />

  </xs:element>
</xs:schema>

The structure of the DiffGram format is shown next. All DiffGrams contains three sections: the current data, the original data, and any errors.

<?xml version="1.0"?>
<diffgr:diffgram 
        xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
        xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <!-- Data goes here. Changed rows are flagged. -->

  <diffgr:before>
     <!-- Contains the original data. -->
  </diffgr:before>

  <diffgr:errors>
     <!-- Contains error information. -->
  </diffgr:errors>

</diffgr:diffgram>

For specific examples that show how you can create a typed DataSet and refine its schema, refer to Chapter 4. For an introduction to the DiffGram format and XML serialization with the DataSet, refer to Chapter 7.



    Part I: ADO.NET Tutorial
    Part II: ADO.NET Core Classes
    Part III: API Quick Reference