Wednesday, July 9, 2014

ADO.NET Data Containers

DataAdapter
In ADO.NET, the data adapter object acts as a two-way bridge between a data source and the DataSet object. 
The DataSet is a disconnected container of data, and the adapter takes care of filling it and submitting its data back to a particular data source. 
From an abstract point of view, a data adapter is similar to a command and represents another way of executing a command against the data source. 
The big difference between commands and data adapters is just in the way each one returns the retrieved data. A query command returns a read-only, forward-only cursor—the data reader. The data adapter performs its data access, grabs all the data, and packs it into an in-memory  container—the DataSet or DataTable. 
DataSet
The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy of the relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database. When the use of this DataSet is finished, changes can be made back to the central database for updating. The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database.
Inside a DataSet, much like in a database, there are tables, columns, relationships, constraints, views, and so forth.
The ADO.NET DataSet is the core component of the disconnected architecture of ADO.NET. The DataSet is explicitly designed for data access independent of any data source. As a result it can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet contains a collection of one or more DataTable objects made up of rows and columns of data, as well as primary key, foreign key, constraint, and relation information about the data in the DataTable objects.