The Microsoft .NET Framework and ADO.NET provide a unified programming model to access data represented as both XML data (text delimited by tags that structure the data) and relational data (tables consisting of rows and columns). This framework reads XML data from any data stream into DOM node trees, where data can be accessed programmatically, while ADO.NET provides the means to access and manipulate relational data within a DataSet object. Here we look at the three key components for data access in ADO.NET and the .NET Framework, as defined in Table 3-7.
Within this table XmlDataDocument is a subclass of the XmlDocument. A .NET application can use the XmlDataDocument to load either relational or XML data and manipulate the data using the DOM. When the XmlDataDocument loads relational data, it synchronizes data between the DataSet and the DOM. After an XmlDataDocument loads relational data, an application can access the data programmatically using the .NET Framework.
Table 3-7 Key Components for Data Access
Component | Description |
---|---|
DataSet | Represents a relational data source in ADO.NET. |
XmlDocument | Implements the DOM in the .NET Framework. |
XmlDataDocument | Unifies ADO.NET and the .NET Framework by repre-senting relational data from a DataSet and synchro-nizing it with the XML document model. |
The classes that comprise the .NET Framework and ADO.NET enable three broad scenarios. In Table 3-4 we cover these scenarios.
Table 3-8 Scenarios Enabled by the Classes
Scenario | Description |
---|---|
Accessing | Create and use a DataSet to access relational data without using XML. Read and write XML data to or from a DataSet without using an XmlDataDocument . (Any XML information not relevant to the relational presentation is lost.) |
Accessing XML documents | Create and use an XmlDocument to access XML data streams. Use structured data in an XmlDataDocument without tables, rows, columns, relationships, and other relational elements. This makes it identical to the XmlDocument. |
Accessing | Structure relational data in an XmlDataDocument with a DataSet. Obtain a DataSet from an XmlDataDocument to relationally view and query the structured content of an XML document. Work with the XML view of relational data in a DataSet. Provide relational and XML-based components for a data application. For example, you can edit and expose relational data without affecting the fidelity of an XML document and apply XSLT to relational data. Performs XPath queries over relational data. |