The DataSet is a memory-resident representation of data including tables, relationships between the tables, and both unique and foreign key constraints. It is used for working with and transporting data in a disconnected environment.
There are four important characteristics of the DataSet :
DataSets exist as both untyped and strongly typed. Strongly typed DataSet s are a collection of automatically generated classes that inherit from the DataSet , DataTable , and DataRow classes, and provide additional properties, methods , and events based on the DataSet schema. A strongly typed DataSet can make programs more intuitive to write and allows the Visual Studio .NET IDE to provide functionality such as autocomplete and for the compiler to detect type mismatch errors and misspelled names during compilation rather than at runtime. Strongly typed DataSet s are discussed in detail in Chapter 13.
The data stored in the DataSet can be manipulated programmatically and populated using a DataAdapter or from XML documents or streams. The actual DataSet schema can be created programmatically, read from a data source, read from an XML schema, or inferred from an XML document or stream. The DataSet can easily be serialized to XML for marshalling between processes with .NET remoting or to meet persistent storage requirements.
Figure 6-1 shows the structure of the DataSet and the contained classes.
Figure 6-1. The DataSet class