Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

CsvDataReader

OfficeIMO.CSV

Namespace
OfficeIMO.CSV
Assembly
OfficeIMO.CSV
Source revision
e163ccb36643 with working tree changes
Base
DbDataReader
Implements
IDataReader IDisposable IDataRecord IEnumerable IAsyncDisposable ICsvDataReaderDialectMetadata ICsvDataReaderMetadata ICsvDataReaderPositionMetadata IDataReaderMappingMetadata IDataReaderMappingErrorMetadata IDataReaderFastMappingValues IDataReaderParallelBatchSource IDataReaderParallelBatchInfo IDataReaderUtf8TextSource
Attributes
DefaultMember("Item")

Forward-only reader for CSV rows projected through an optional schema.

Inheritance

  • DbDataReader
  • CsvDataReader

Usage

Explore 3 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Methods

public override void Close() #

Closes the DbDataReader object.

public override bool GetBoolean(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a Boolean.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

bool The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override byte GetByte(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a byte.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

byte The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override long GetBytes(int ordinal, long dataOffset, byte[]? buffer, int bufferOffset, int length) #

When overridden in a derived class, reads a specified number of bytes from the specified column starting at a specified index and writes them to a buffer starting at a specified position in the buffer.

Parameters

ordinal int required
The zero-based column ordinal.
dataOffset long required
The index within the row from which to begin the read operation.
buffer byte[]? required
The buffer into which to copy the data.
bufferOffset int required
The index with the buffer to which the data will be copied.
length int required
The maximum number of bytes to read.

Returns

long The actual number of bytes read.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override char GetChar(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a single character.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

char The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override long GetChars(int ordinal, long dataOffset, char[]? buffer, int bufferOffset, int length) #

When overridden in a derived class, reads a specified number of characters from a specified column starting at a specified index, and writes them to a buffer starting at a specified position.

Parameters

ordinal int required
The zero-based column ordinal.
dataOffset long required
The index within the row from which to begin the read operation.
buffer char[]? required
The buffer into which to copy the data.
bufferOffset int required
The index with the buffer to which the data will be copied.
length int required
The maximum number of characters to read.

Returns

long The actual number of characters read.
public override string GetDataTypeName(int ordinal) #

When overridden in a derived class, gets name of the data type of the specified column.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

string The name of the data type.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
public override DateTime GetDateTime(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a DateTime object.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

DateTime The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override decimal GetDecimal(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a decimal.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

decimal The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override double GetDouble(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a double-precision floating point number.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

double The value of the specified column.

Exceptions

  • InvalidCastException – The specified cast is not valid.
public override IEnumerator GetEnumerator() #

When overridden in a derived class, returns an enumerator that can be used to iterate through the rows in the data reader.

Returns

IEnumerator An enumerator that can be used to iterate through the rows in the data reader.
public override Type GetFieldType(int ordinal) #

When overridden in a derived class, gets the data type of the specified column.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

Type The data type of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override T? GetFieldValue<T>(int ordinal) #

Gets the value of the specified column as the requested type.

Type Parameters

T
The type of the value to be returned.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

T? The value of the specified column.

Exceptions

  • InvalidOperationException – The connection was dropped or closed during data retrieval. -or- The data reader was closed during data retrieval. -or- There is no data ready to be read (for example, the first DbDataReader.Read hasn't been called, or it returned false). -or- The reader tried to read a previously-read column in sequential mode. -or- There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.
  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The value returned by the database doesn't match or cannot be cast to T.
public override float GetFloat(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a single-precision floating point number.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

float The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override Guid GetGuid(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a globally unique identifier (GUID).

Parameters

ordinal int required
The zero-based column ordinal.

Returns

Guid The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override short GetInt16(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a 16-bit signed integer.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

short The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override int GetInt32(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a 32-bit signed integer.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

int The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override long GetInt64(int ordinal) #

When overridden in a derived class, gets the value of the specified column as a 64-bit signed integer.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

long The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override string GetName(int ordinal) #

When overridden in a derived class, gets the name of the column, given the zero-based column ordinal.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

string The name of the specified column.
public override int GetOrdinal(string name) #

When overridden in a derived class, gets the column ordinal given the name of the column.

Parameters

name string required
The name of the column.

Returns

int The zero-based column ordinal.

Exceptions

  • IndexOutOfRangeException – The name specified is not a valid column name.
public override DataTable GetSchemaTable() #

Returns a DataTable that describes the column metadata of the DbDataReader. Returns null if the executed command returned no resultset, or after DbDataReader.NextResult returns false.

Returns

DataTable A DataTable that describes the column metadata.

Exceptions

  • InvalidOperationException – The DbDataReader is closed.
  • IndexOutOfRangeException – The column index is out of range.
  • NotSupportedException – .NET Core and .NET 5+ only: In all cases.
public override string GetString(int ordinal) #

When overridden in a derived class, gets the value of the specified column as an instance of string.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

string The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
  • InvalidCastException – The specified cast is not valid.
public override object GetValue(int ordinal) #

When overridden in a derived class, gets the value of the specified column as an instance of object.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

object The value of the specified column.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
public override int GetValues(object[] values) #

When overridden in a derived class, populates an array of objects with the column values of the current row.

Parameters

values object[] required
An array of object into which to copy the attribute columns.

Returns

int The number of instances of object in the array.
public override bool IsDBNull(int ordinal) #

When overridden in a derived class, gets a value that indicates whether the column contains nonexistent or missing values.

Parameters

ordinal int required
The zero-based column ordinal.

Returns

bool true if the specified column is equivalent to DBNull; otherwise, false.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
public override bool NextResult() #

When overridden in a derived class, advances the reader to the next result when reading the results of a batch of statements.

Returns

bool true if there are more result sets; otherwise, false.
public override Task<bool> NextResultAsync(CancellationToken cancellationToken) #

Asynchronously advances the reader to the next result when reading the results of a batch of statements.

Parameters

cancellationToken System.Threading.CancellationToken required
The cancellation instruction.

Returns

Task<bool> A Task<T> whose Task<T>.Result property is true if there are more result sets or false if there aren't.

Exceptions

  • DbException – An error occurred while executing the command text.
public override bool Read() #

When overridden in a derived class, advances the reader to the next record in a result set.

Returns

bool true if there are more rows; otherwise, false.
public override Task<bool> ReadAsync(CancellationToken cancellationToken) #

Asynchronously advances the reader to the next record in a result set.

Parameters

cancellationToken System.Threading.CancellationToken required
The cancellation instruction.

Returns

Task<bool> A Task<T> whose Task<T>.Result property is true if there are more rows or false if there aren't.

Exceptions

  • DbException – An error occurred while executing the command text.
public virtual bool TryGetUtf8Text(int ordinal, out ReadOnlySpan<byte> text) #

Borrows normalized text only when the current source already holds its exact UTF-8 bytes. Conversion, missing values and canonical text-parser fallbacks remain unavailable.

Parameters

ordinal int required
text System.ReadOnlySpan<byte> required

Returns

bool

Properties

public override object this[int ordinal] { get; } #

When overridden in a derived class, gets the value of the specified column as an instance of object.

Parameters

ordinal int required
The zero-based column ordinal.

Exceptions

  • IndexOutOfRangeException – The column index is out of range.
public override object this[string name] { get; } #

When overridden in a derived class, gets the value of the specified column as an instance of object.

Parameters

name string required
The name of the column.

Exceptions

  • IndexOutOfRangeException – No column with the specified name was found.
public override int Depth { get; } #

Gets a value indicating the depth of nesting for the current row.

public virtual char Delimiter { get; } #

Gets the delimiter used to parse the reader input, including a delimiter selected by detection.

public virtual string DelimiterText { get; } #

Gets the complete single- or multi-character input delimiter.

public virtual long RecordNumber { get; } #

Gets the one-based data-record number after header, comment, blank, and skipped-record handling. Returns zero when the reader is not positioned on a row.

public virtual int? PhysicalLineNumber { get; } #

Gets the one-based physical source line on which the current record starts, when retained by the reader path. Returns null when unavailable or when the reader is not positioned on a row.

public virtual int? PhysicalEndLineNumber { get; } #

Gets the one-based physical source line on which the current record ends, when retained by the reader path. This differs from ICsvDataReaderPositionMetadata.PhysicalLineNumber for multiline quoted records.

public override int FieldCount { get; } #

When overridden in a derived class, gets the number of columns in the current row.

Exceptions

  • NotSupportedException – There is no current connection to an instance of SQL Server.
public override bool HasRows { get; } #

When overridden in a derived class, gets a value that indicates whether this DbDataReader contains one or more rows.

public override bool IsClosed { get; } #

When overridden in a derived class, gets a value indicating whether the DbDataReader is closed.

Exceptions

  • InvalidOperationException – The DbDataReader is closed.
public override int RecordsAffected { get; } #

When overridden in a derived class, gets the number of rows changed, inserted, or deleted by execution of the SQL statement.