The ADO.Net Object Model

The ADO.Net object model is rich, but at its heart it is a fairly straightforward set of classes. The most important of these is the DataSet . The DataSet represents a subset of the entire database, cached on your machine without a continuous connection to the database.

Periodically, you’ll reconnect the DataSet to its parent database, update the database with changes you’ve made to the DataSet, and update the DataSet with changes in the database made by other processes.

This is highly efficient, but to be effective the DataSet must be a robust subset of the database, capturing not just a few rows from a single table, but a set of tables with all the metadata necessary to represent the relationships and constraints of the original database. This is, not surprisingly, what ADO.NET provides.

The DataSet is composed of DataTable objects as well as DataRelation objects. These are accessed as properties of the DataSet object. The DataTables property returns a TablesCollection , which in turn contains all the DataTable objects.

DataTables and DataColumns

The DataTable can be created programmatically or as a result of a query against the database. The DataTable has a number of public properties, including the Columns collection, which returns the ColumnsCollection object, which in turn consists of DataColumn objects. Each DataColumn object represents a column in a table.

DataRelations

In addition to the DataTables collection, the DataSet has a Relations property, ...

Get Programming C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.