The ADO.NET Object Model

The goal of ADO.NET is to provide a bridge between your objects in .NET and your backend database. ADO.NET provides an object-oriented API to a relational view of your database, encapsulating many of the database properties and relationships within ADO.NET objects. More importantly, the ADO.NET objects encapsulate and hide the details of database access; your objects can interact with ADO.NET objects without knowing or worrying about the details of how the data is moved to and from the database.

The DataSet Class

The ADO.NET object model is rich, but at its heart is a fairly straightforward set of classes. One very powerful class, key to the disconnected architecture, is the DataSet, which is located in the System.Data namespace.

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.

The DataSet captures not just a few rows from a single table, but represents a set of tables with all the metadata necessary to represent the relationships and constraints among the tables as recorded in the original database.

The DataSet offers two key properties: Tables and Relations. The Tables property returns a collection of DataTables. Each DataTable, in turn, has two important properties: Columns ...

Get Programming .NET Windows Applications 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.