ADO. NET provides the following two objects for retrieving relational data and storing it in memory:
Provides a relational representation of data in the memory, a set of data including some tables (these tables contain data, sort the data and constrain the data), and the relationship between tables. Datareader provides a fast, forward-only, read-only data stream from the database.
Dataadapter (or commandbuilder) is often used to interact with the data source. When using
You can also use dataview
Data Application sorting in
Filter. You can also
Inherit, create a strong type
Used to split tables and rows
Columns are published as strong object attributes.
When designing an application, consider the level of functionality required by the application to determine the use
R is used to navigate between multiple discrete tables in the result.
R operations come from multiple data sources (for example, from multiple databases and an XML file)
Data of a workbook.
R exchanges data between layers or uses XML Web Services. Unlike datareader,
Can be passed to the remote client.
R reuse the same set of records to improve performance (such as sorting, searching, or filtering data) through caching ).
R each record requires a large amount of processing. Extended processing of each row returned by datareader will prolong the necessary time to serve the datareader connection, which affects the performance.
R uses XML operations to operate data, such as extensible style sheet language conversion (XSLT conversion) or XPath query.
Use DataReader in applications in the following cases:
R does not need to cache data.
The result set to be processed by r is too large to be stored in the memory.
Once r needs to access data in a forward-only and read-only manner.
Note FillingDataSetThe DataAdapter uses DataReader. Therefore, use DataAdapter to replaceDataSetThe performance is reduced.DataSetMemory usageAndFillDataSetLoop. Generally, this performance improvement is symbolic. Therefore, design decisions should be based on the required functions.