Understanding ADO.NET Disconnected Classes


ADO.NET disconnected classes are the basic building blocks of the ADO.NET architecture. These classes loosely couple with data providers. The System.Data namespace defines these classes.

The System.Data Namespace

The System.Data namespace consists of classes that are the basic building blocks of the ADO.NET architecture. These classes are also known as disconnected classes because they store disconnected data and can work without data providers.

Table 3-1 describes some of the common classes of the System.Data namespaces. We discuss these classes in more detail throughout this chapter.

Table 3-1: The System.Data Namespace Classes

CLASS

DESCRIPTION

Constraint, ConstraintCollection, UniqueConstraint, ForeignKeyConstraint

Constraints are rules set on a database table and its columns to help maintain the integrity of the data or to enforce business rules. The Constraint class object represents a constraint that you can apply on a DataColumn object. Some of these constraints are primary key, uniqueness, and foreign key. The ConstraintCollection class represents a collection of constraints for a DataTable. UniqueConstraint and ForeignKeyConstraint represent unique and foreign key constraints.

DataColumn, DataColumnCollection

The DataColumn object represents a column of a table. DataColumnCollection represents a collection of columns of a table.

DataRelation, DataRelationCollection

The DataRelation object represents a parent/child relationship between two DataTable objects. DataRelationCollection represents a collection of DataRelation.

DataRow, DataRowCollection

A DataRow object represents a row of a table, and DataRowCollection represent a collection of rows.

DataRowView

DataRowView represents a view of DataRow. It's useful when you want to attach a DataRow with data-bound controls such as a DataGrid.

DataSet

In ADO.NET, a DataSet object is a replacement of the ADO recordset and represents an in-memory cache of data. A DataSet is a collection of DataTable objects.

DataTable, DataTableCollection

A DataTable object represents an in-memory cache of a table, and DataTableCollection is a collection of one or more DataTable objects.

DataView

Represents a data-bindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation.

DataViewManager

The DefaultViewManager represents the default view of a DataSet or DataTableCollection.

The System.Data namespace also defines many enumerations and delegates that we discuss throughout this chapter.

Once you have an idea of what classes the System.Data.Common namespace constaints, you'll have no problem understanding how to use these classes in a sample application.

The System.Data.Common Namespace

As its name says, the System.Data.Common namespace contains classes shared by the .NET data providers. Some of these classes are the base classes for the .NET data provider classes. Table 3-2 defines some of these classes.

Table 3-2: The System.Data.Common Namespace Classes

CLASS

DESCRIPTION

DataAdapter

The DataAdapter class represents a DataAdapter that works as a bridge between a data source and DataSet. It implements the Fill and Update methods. The Fill method fills data from a data source to a DataSet using Command objects. This class is a base class for the DbDataAdapter class, which itself is a base class for the OleDbDataAdapter, SqlDataAdapter, and ODBC DataAdapter classes. These classes are discussed in the "The DataAdapter: Adapting to Your Environment" section of Chapter 4.

DataColumnMapping

If you don't want to use the default column names of a table to access these columns, you can define your own names. You map your custom names with the original column names through DataAdapters and use these names in your application. The SourceColumn and DataSetColumn properties of this class represent the source column name and DataSet column name.

DataColumnMappingCollection

Collection of DataColumnMapping objects.

DataTableMapping

You can even map a database table to a DataTable and use this DataTable as the source in your applications. The ColumnMappings property returns DataColumnMappingCollection for the DataTable. The DataSetTable and SourceTable properties represent the DataTable and source tables.

DataTableMappingCollection

Collection of DataTableMapping objects.

DbDataAdapter

Inherited from DataAdapter, this class implements the IdbDataAdapter interface. This class is used as the base class of a data provider's DataAdapter classes.

DBDataPermission

Ensures that data providers have security to access data. This class is a base class from the OleDbDataPermission, OdbcDataPermission, and SqlDataPermission classes.




Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net