DataSet or Reader or what?

When using a class to get one row of data from a database, what is the best way to use:

  • DataSet?
  • A reader and do what stores data in a structure?
  • What else?

Thanks for your time, Nathan.

+3
source share
4 answers

DataReader is always your best bet - provided it is compatible with your use. DataReaders are very fast, efficient, and lightweight - but they do require that you maintain an active / open db connection for your life cycle, which means that they cannot be distributed across AppDomains (or via web services, etc.).

DataReaders - ( , ) , ( DTO) , AppDomains webservices.

"DataReaders ADO.NET ONLINE (, , db ), DataSets ADO.NET OFFLINE ( ).

+3

DataAdapter ( DataSet) DataReader .

, DataReader , DataAdapter. DataSets DataTables . , , .

, MS SQL Server ( ).

0

, , DataReader dataGrid, , Datatable

:

0

, DataReader; .

However, if you intend to change the data and save it back to the database, I would recommend using the DataAdapter and DataSet (even a typed DataSet), because the DataSet class takes care of tracking changes, additions and deletions, which saves a lot. In addition, if there are several tables in a dataset, you can model the relational constraints between them in the dataset.

0
source

Source: https://habr.com/ru/post/1755993/


All Articles