We think that dataset is not good for two reasons: 1. dataset and non. net code interaction is not very good, it is difficult to use dataset Web Services API and does not support.. NET Framework system interaction; 2. dataset is a very common container, and programmers may sacrifice some.. NET Framework.
Dataset was designed to serve as an offline cache for relational databases. It can store many geek datatables, and each able is stored in database-matched rows and columns, dataset and its members support data binding. In addition, dataset also supports the relationship between data tables and adds constraints to data in dataset.
Dataset is not a strongly typed container. It is a dictionary set about datatable, and the columns in the datatable are also a dictionary structure. We usually use the following methods to access data in dataset.
int val = ( int )MyDataSet.Tables[ "table1" ].Rows[ 0 ][ "total" ];
There are two problems: 1. the data in dataset is system. object type. When the program is in use, forced type conversion is also required; 2. when accessing data in dataset, you also need to use hard encoding to locate the table name and column name.
Generally, we want the following statements to access data in dataset.
int val = MyDataSet.table1.Rows[ 0 ].total;
If you want to access data in dataset in this way, you can use either of the following methods: 1. use of strong dataset (this is not recommended for individuals, because it is difficult to ensure the stability of the data structure in the system development phase); 2. use an ORM framework, such as nhib.pdf. Avoid writing data storage structures by yourself.