The core component of ADO. NET is composed of the data provider module and the dataset module. Data ProviderProgramDatabase to achieve data connection, operations, and fast read-only access to data. Dataset allows data access and Operations independent from data sources. It is similar to the closed static data set of ADO.
The structure of ADO. NET is as follows:
1... NET Framework data provider
The. NET Framework data provider is a set of connection data sources that can execute commands on data to obtain the program structure of data.
(1) Four data providers of. NET Framework
. NET Framework provides four sets of data providers for accessing four types of data sources.
1. SQL Server. NET Framework data provider. This program can only access ms SQL Server7.0 or a later version. Earlier versions can only be accessed through the OLE DB data provider. Its namespace is system. Data. sqlclient.
2. The ole db. NET Framework data provider is used to access the ole db data provider. This program does not support the ole db 2.5 interface. Its namespace is system. Data. oledb.
3. ODBC. NET Framework data provider. Used to access the ODBC data provider. Its namespace is system. Data. ODBC.
4. Oracle. NET Framework data provider. Used to access Oracle data. This program must be supported by Oracle client software 8.1.7 or later. Its namespace is system. Data. oracleclient.
Through implementation of idbconnection, idbcommand, idataadapter, idbdataadapter, idatareader, idataparameter, and idbtransaction, you can also write your own data provider groups.
(2) four core objects of the. NET data provider
. NET data providers usually contain four core objects:
1. The connection object provides a connection to the data source. The connection class of the data provider inherits the implementation of the system. Data. idbconnection interface.
2. The command object allows you to access database commands used to return data, modify data, run stored procedures, and send or retrieve parameter information. The command class of the data provider inherits the implementation of the system. Data. idbcommand interface.
3. datareader provides high-performance data streams from the data source. Datareader data streams are read-only. The datareader class of the data provider inherits the implementation of the system. Data. idatareader interface.
4. dataadapter provides a bridge between dataset objects and data sources. Dataadapter uses the command object to execute SQL commands in the data source to load data to dataset and make changes to the data in dataset consistent with the data source. The dataadapter class of the data provider inherits the implementation of the system. Data. idbdataadapter interface.
. NET data providers also include transaction objects and parameter objects.
Ii.. NET Framework Dataset
Connections, commands, transactions, and data reads act on specific providers. Only datasets can be provided independently of specific data. the namespace of the DataSet object dataset in the. NET Framework is located in system. data.
(1) DataSet object model
Dataset objects are the core objects that support ADO. Net's disconnected and distributed data solutions. Dataset is the memory resident representation of data. It provides consistent relational programming models no matter what the data source is. You can think of it as a relational database concentrated in the memory. Its object model is as follows:
Dataset contains three sets:
(1) datatablecollection. The most important object in a relational database is table. This set is used in dataset to contain multiple able objects. A able is a data table in memory. You can identify a table by a unique name. The maximum number of data rows that can be stored by dataset datatable is 16,777,216.
(2) datarelationcollection. In addition to tables, relational databases also have relationship relation between tables. This is a set of table link objects.
(3) extendedproperties. This is a set of custom information, which is similar to ASP session.
(2) dataset and dataadapter
The dataadapter object is a bridge between the data provider and dataset. The dataadapter class of the data provider is implemented by idataadapter or idbdataadapter. Generally, the constructor of dataadapter is:
Xxxdataadapter (sqlcommand selectcommand)
Xxxdataadapter (string selectcommandtext, string selectconnectionstring)
Xxxdataadapter (string selectcommandtext, sqlconnection selectconnection)
Dataadapter adds data sources and architectures to dataset by implementing fill and fillschema, and updates data in dataset to the data source through update.