EntityDataReader 类

定义

从数据源中读取行的只进流。Reads a forward-only stream of rows from a data source.

public ref class EntityDataReader : System::Data::Common::DbDataReader, System::Data::IExtendedDataRecord
public class EntityDataReader : System.Data.Common.DbDataReader, System.Data.IExtendedDataRecord
type EntityDataReader = class
    inherit DbDataReader
    interface IExtendedDataRecord
    interface IDataRecord
Public Class EntityDataReader
Inherits DbDataReader
Implements IExtendedDataRecord
继承
实现

注解

组合了 DbDataReader 类和 IExtendedDataRecord 接口的功能。Combines the functionality of the DbDataReader class and the IExtendedDataRecord interface.

EntityDataReader 没有公共构造函数。An EntityDataReader has no public constructor. 它只能通过方法重载之一来获取 EntityCommand.ExecuteReaderIt can only be obtained through one of the EntityCommand.ExecuteReader method overloads.

SQL Server SQL Server puts output parameters from stored procedures at the end of the result stream, after all the result sets. 因此,为了获取输出参数值,应用程序必须耗用所有结果集中的所有记录。Therefore, to get output parameter values, an application must consume all the records in all the result sets. 如果应用程序关闭 EntityDataReader(这将同时关闭 DbDataReader),那么输出参数可能未填充值。If the application closes the EntityDataReader (which would also close the DbDataReader), output parameters might not be populated.

EntityDataReader 不会隐式耗用结果集以使输出参数可用。EntityDataReader does not implicitly consume result sets to make output parameters available. 因此,请注意以下几点:Therefore, note the following:

有关代码示例,请参阅使用 EntityClientFor code examples, see Working with EntityClient.

属性

DataRecordInfo

获取此 DataRecordInfoIExtendedDataRecordGets DataRecordInfo for this IExtendedDataRecord.

Depth

获取一个值,该值指示当前行的嵌套深度。Gets a value indicating the depth of nesting for the current row.

FieldCount

获取当前行中的列数。Gets the number of columns in the current row.

HasRows

获取一个值,该值指示此 EntityDataReader 是否包含一个或多个行。Gets a value that indicates whether this EntityDataReader contains one or more rows.

IsClosed

获取一个值,该值指示 EntityDataReader 是否已关闭。Gets a value indicating whether the EntityDataReader is closed.

Item[Int32]

Object 实例的形式获取指定列的值。Gets the value of the specified column as an instance of Object.

Item[String]

Object 实例的形式获取指定列的值。Gets the value of the specified column as an instance of Object.

RecordsAffected

通过执行 SQL 语句获取更改、插入或删除的行数。Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.

VisibleFieldCount

获取 EntityDataReader 中未隐藏的字段的数目。Gets the number of fields in the EntityDataReader that are not hidden.

方法

Close()

关闭 EntityDataReader 对象。Closes the EntityDataReader object.

CloseAsync()

异步关闭 DbDataReader 对象。Asynchronously closes the DbDataReader object.

(继承自 DbDataReader)
CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Dispose()

释放 DbDataReader 类的当前实例所使用的所有资源。Releases all resources used by the current instance of the DbDataReader class.

(继承自 DbDataReader)
Dispose(Boolean)

释放由此 EntityDataReader 占用的资源并调用 Close()Releases the resources consumed by this EntityDataReader and calls Close().

DisposeAsync()

异步释放 DbDataReader 类的当前实例所使用的所有资源。Asynchronously releases all resources used by the current instance of the DbDataReader class.

(继承自 DbDataReader)
Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetBoolean(Int32)

获取指定列的布尔值形式的值。Gets the value of the specified column as a Boolean.

GetByte(Int32)

以字节的形式获取指定列的值。Gets the value of the specified column as a byte.

GetBytes(Int32, Int64, Byte[], Int32, Int32)

从指定列读取一个字节流(从 dataIndex 指示的位置开始),读到缓冲区中(从 bufferIndex 指示的位置开始)。Reads a stream of bytes from the specified column, starting at location indicated by dataIndex, into the buffer, starting at the location indicated by bufferIndex.

GetChar(Int32)

作为单个字符获取指定列的值。Gets the value of the specified column as a single character.

GetChars(Int32, Int64, Char[], Int32, Int32)

从指定列读取一个字符流,从 dataIndex 指示的位置开始,读到缓冲区中,从 bufferIndex 指示的位置开始。Reads a stream of characters from the specified column, starting at location indicated by dataIndex, into the buffer, starting at the location indicated by bufferIndex.

GetColumnSchemaAsync(CancellationToken)

这是 GetColumnSchema(DbDataReader) 的异步版本。This is the asynchronous version of GetColumnSchema(DbDataReader). 提供程序应使用合适的实现进行重写。Providers should override with an appropriate implementation. 可以选择接受 cancellationTokenThe cancellationToken can optionally be honored. 默认实现调用同步 GetColumnSchema(DbDataReader) 调用并返回已完成任务。The default implementation invokes the synchronous GetColumnSchema(DbDataReader) call and returns a completed task. 如果传递到已取消 cancellationToken,则默认实现将返回已取消的任务。The default implementation will return a cancelled task if passed an already cancelled cancellationToken. GetColumnSchema(DbDataReader) 引发的异常将通过任务异常属性传递。Exceptions thrown by GetColumnSchema(DbDataReader) will be communicated via the returned Task Exception property.

(继承自 DbDataReader)
GetData(Int32)

返回所请求列的嵌套数据读取器。Returns a nested data reader for the requested column.

(继承自 DbDataReader)
GetDataReader(Int32)

DbDataReader 对象的形式返回嵌套的读取器。Returns nested readers as DbDataReader objects.

GetDataRecord(Int32)

返回嵌套的 DbDataRecordReturns a nested DbDataRecord.

GetDataTypeName(Int32)

获取指定列的数据类型的名称。Gets the name of the data type of the specified column.

GetDateTime(Int32)

DateTime 对象的形式获取指定列的值。Gets the value of the specified column as a DateTime object.

GetDbDataReader(Int32)

为可用提供程序特定的实现重写的已请求的列序号返回一个 DbDataReader 对象。Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation.

GetDecimal(Int32)

Decimal 对象的形式获取指定列的值。Gets the value of the specified column as a Decimal object.

GetDouble(Int32)

获取作为双精度浮点数的指定列的值。Gets the value of the specified column as a double-precision floating point number.

GetEnumerator()

返回一个可用于循环访问数据读取器中的行的 IEnumeratorReturns an IEnumerator that can be used to iterate through the rows in the data reader.

GetFieldType(Int32)

获取指定列的数据类型。Gets the data type of the specified column.

GetFieldValue<T>(Int32)

获取指定列的值作为请求的类型。Gets the value of the specified column as the requested type.

(继承自 DbDataReader)
GetFieldValueAsync<T>(Int32)

异步获取指定列的值作为请求的类型。Asynchronously gets the value of the specified column as the requested type.

(继承自 DbDataReader)
GetFieldValueAsync<T>(Int32, CancellationToken)

异步获取指定列的值作为请求的类型。Asynchronously gets the value of the specified column as the requested type.

(继承自 DbDataReader)
GetFloat(Int32)

以单精度浮点数字的形式获取指定列的值。Gets the value of the specified column as a single-precision floating point number.

GetGuid(Int32)

以全局唯一标识符 (GUID) 的形式获取指定列的值。Gets the value of the specified column as a globally-unique identifier (GUID).

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetInt16(Int32)

获取指定列的 16 位有符号整数形式的值。Gets the value of the specified column as a 16-bit signed integer.

GetInt32(Int32)

获取指定列的 32 位带符号整数形式的值。Gets the value of the specified column as a 32-bit signed integer.

GetInt64(Int32)

以 64 位有符号整数的形式获取指定列的值。Gets the value of the specified column as a 64-bit signed integer.

GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetName(Int32)

在给定从零开始的列序号时获取该列的名称。Gets the name of the column, given the zero-based column ordinal.

GetOrdinal(String)

在给定列名时获取相应的列序号。Gets the column ordinal given the name of the column.

GetProviderSpecificFieldType(Int32)

返回指定列的提供程序特定的字段类型。Returns the provider-specific field type of the specified column.

GetProviderSpecificValue(Int32)

Object 实例的形式获取指定列的值。Gets the value of the specified column as an instance of Object.

GetProviderSpecificValues(Object[])

在当前行的集合中获取提供程序特定的所有属性列。Gets all provider-specific attribute columns in the collection for the current row.

GetSchemaTable()

返回一个 DataTable,它描述 DbDataReader 的列元数据。Returns a DataTable that describes the column metadata of the DbDataReader.

GetSchemaTableAsync(CancellationToken)

这是 GetSchemaTable() 的异步版本。This is the asynchronous version of GetSchemaTable(). 提供程序应使用合适的实现进行重写。Providers should override with an appropriate implementation. 可以选择接受 cancellationTokenThe cancellationToken can optionally be honored. 默认实现调用同步 GetSchemaTable() 调用并返回已完成任务。The default implementation invokes the synchronous GetSchemaTable() call and returns a completed task. 如果传递到已取消 cancellationToken,则默认实现将返回已取消的任务。The default implementation will return a cancelled task if passed an already cancelled cancellationToken. GetSchemaTable() 引发的异常将通过任务异常属性传递。Exceptions thrown by GetSchemaTable() will be communicated via the returned Task Exception property.

(继承自 DbDataReader)
GetStream(Int32)

获取从指定列检索数据的流。Gets a stream to retrieve data from the specified column.

(继承自 DbDataReader)
GetString(Int32)

String 实例的形式获取指定列的值。Gets the value of the specified column as an instance of String.

GetTextReader(Int32)

获取文本读取器以从列中检索数据。Gets a text reader to retrieve data from the column.

(继承自 DbDataReader)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetValue(Int32)

Object 实例的形式获取指定列的值。Gets the value of the specified column as an instance of Object.

GetValues(Object[])

使用当前行的列值来填充对象数组。Populates an array of objects with the column values of the current row.

InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
IsDBNull(Int32)

获取一个值,该值指示列中是否包含不存在或丢失的值。Gets a value that indicates whether the column contains nonexistent or missing values.

IsDBNullAsync(Int32)

异步获取一个值,该值指示列中是否包含不存在的或缺少的值。Asynchronously gets a value that indicates whether the column contains non-existent or missing values.

(继承自 DbDataReader)
IsDBNullAsync(Int32, CancellationToken)

异步获取一个值,该值指示列中是否包含不存在的或缺少的值。Asynchronously gets a value that indicates whether the column contains non-existent or missing values.

(继承自 DbDataReader)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
NextResult()

在读取一批语句的结果时,使读取器前进到下一个结果。Advances the reader to the next result when reading the results of a batch of statements.

NextResultAsync()

在读取一批语句的结果时,使读取器异步前进到下一个结果。Asynchronously advances the reader to the next result when reading the results of a batch of statements.

(继承自 DbDataReader)
NextResultAsync(CancellationToken)

在读取一批语句的结果时,使读取器异步前进到下一个结果。Asynchronously advances the reader to the next result when reading the results of a batch of statements.

(继承自 DbDataReader)
Read()

使读取器前进到结果集中的下一条记录。Advances the reader to the next record in a result set.

ReadAsync()

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

(继承自 DbDataReader)
ReadAsync(CancellationToken)

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

(继承自 DbDataReader)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

IDataReader.Close()

有关此成员的说明,请参见 Close()For a description of this member, see Close().

(继承自 DbDataReader)
IDataReader.GetSchemaTable()

有关此成员的说明,请参见 GetSchemaTable()For a description of this member, see GetSchemaTable().

(继承自 DbDataReader)
IDataRecord.GetData(Int32)

有关此成员的说明,请参见 GetData(Int32)For a description of this member, see GetData(Int32).

(继承自 DbDataReader)

扩展方法

CanGetColumnSchema(DbDataReader)

获取一个值,指示 DbDataReader 是否可以获取列架构。Gets a value that indicates whether a DbDataReader can get a column schema.

GetColumnSchema(DbDataReader)

获取 DbDataReader 的列架构(DbColumn 集合)。Gets the column schema (DbColumn collection) for a DbDataReader.

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于