DataReader与数据集 [英] DataReader Vs Dataset

查看:122
本文介绍了DataReader与数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么DataReader比DataSet更快?

Why DataReader is Faster than DataSet?

推荐答案

数据读取器是一个只转发和只读数据

DataSet用于维护多个

表之间的关系。



数据读取器无法保存数据

数据集可以保留数据



datareader(面向连接)是一个只读和转发

唯一的记录集,它将根据

select语句。我们不能通过

datareader进行DML操作。



而数据集(断开连接)模型哪个我们可以完成所有的B $ B $ DML操作。
Data Reader is a forward only and read only data
DataSet is used to maintain relationships between multiple
tables.

Data Reader can't persist the data
Data Set can persist the data

datareader(connection oriented) is a read only and forward
only record set which will have the data retrieved based on
the select statement.we can't do DML operations through
datareader.

whereas dataset(disconnected) model which we can do all the
DML operations.


在选择数据访问技术时,要考虑的是性能和可伸缩性。正如这些比较所示,通过选择一种数据访问技术而不是另一种数据访问技术,吞吐量通常可以成倍增加,但在所有情况下,没有一种方法能够表现更好由于整体性能受到如此多因素的影响,因此使用实际场景无法替代性能测试。

http://msdn.microsoft.com/en-us/library/ms978388.aspx [ ^ ]


什么是DataReader?



DataReader是在查询执行时从数据库返回的只读数据流。它一次只在内存中包含一行数据,并且仅限于在结果中一次向前导航一条记录。 DataReader支持访问多个结果集,但一次只能检索一个结果集。与ADO的原始版本一样,一旦与数据源的连接关闭,数据不再可通过DataReader获得,这意味着DataReader在整个使用过程中需要连接到数据库。输出参数或返回值仅在连接关闭后才能通过DataReader获得。





什么是数据集?



DataSet是ADO.NET断开连接体系结构的核心,用于以断开状态存储数据。它旨在完全支持XML的使用,因此可以将XML文档读入DataSet,也可以将DataSet导出为XML。这允许DataSet轻松地通过网络传输,因此它可以用作Web服务或其他类型的远程调用的返回。对DataSet的更改可以传播回数据源自的数据源。 DataSet可以向前或向后完全导航,可以根据需要对内容进行过滤,排序或搜索,从而可以在任何给定点访问所有记录。
What is a DataReader?

A DataReader is a read-only stream of data returned from the database as the query executes. It only contains one row of data in memory at a time and is restricted to navigating forward only in the results one record at a time. The DataReader does support access to multiple result sets, but only one at a time and in the order retrieved. Just as in the original version of ADO, the data is no longer available through the DataReader once the connection to the data source is closed, which means a DataReader requires a connection to the database throughout its usage. Output parameters or return values are only available through the DataReader once the connection is closed.


What is a DataSet?

DataSet is the core of the ADO.NET disconnected architecture and is used to store data in a disconnected state. It was designed to fully support the use of XML so an XML document can be read into a DataSet or a DataSet can be exported to XML. This allows a DataSet to be easily transported across a network so it can be used as a return from a Web service or other type of remote call. Changes to a DataSet can be propagated back to the data source from where the data originated. A DataSet is fully navigable forward or backward and the contents can be filtered, sorted, or searched as desired, making all records accessible at any given point.


这篇关于DataReader与数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆