DbDataReader.GetEnumerator DbDataReader.GetEnumerator DbDataReader.GetEnumerator DbDataReader.GetEnumerator Method

定义

当在派生类中重写时,返回一个枚举器,可用于循环访问数据读取器中的行。When overridden in a derived class, returns an enumerator that can be used to iterate through the rows in the data reader.

public:
 abstract System::Collections::IEnumerator ^ GetEnumerator();
public abstract System.Collections.IEnumerator GetEnumerator ();
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
Public MustOverride Function GetEnumerator () As IEnumerator

返回

一个枚举器,可用于循环访问数据读取器中的行。An enumerator that can be used to iterate through the rows in the data reader.

实现

注解

尽管可以使用此方法来检索显式构造函数,但在支持显式foreach构造的语言中,直接使用循环构造来循环访问数据读取器中的行更为简单。Although you can use this method to retrieve an explicit constructor, in languages that support an explicit foreach construct, it is simpler to use the looping construct directly in order to iterate through the rows in the data reader.

如果实现此方法,则它应返回的DbEnumerator新实例,或确保枚举器返回IDataRecord对象。If you implement this method, it should return a new instance of DbEnumerator or ensure that your enumerator returns IDataRecord objects.

适用于

另请参阅