Table of Contents

Class DataReaderWrapper

Namespace
FluentCommand.Merge
Assembly
FluentCommand.SqlServer.dll

Wraps an IDataReader and optionally applies a prefix to field names when accessing data.

public class DataReaderWrapper : IDataReader, IDataRecord, IDisposable
Inheritance
DataReaderWrapper
Implements
Inherited Members

Constructors

DataReaderWrapper(IDataReader)

Initializes a new instance of the DataReaderWrapper class with the specified data reader.

public DataReaderWrapper(IDataReader dataReader)

Parameters

dataReader IDataReader

The underlying IDataReader to wrap.

DataReaderWrapper(IDataReader, string)

Initializes a new instance of the DataReaderWrapper class with the specified data reader and field prefix.

public DataReaderWrapper(IDataReader dataReader, string fieldPrefix)

Parameters

dataReader IDataReader

The underlying IDataReader to wrap.

fieldPrefix string

The prefix to apply to field names when accessing data, or null for no prefix.

Properties

Depth

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

public int Depth { get; }

Property Value

int

FieldCount

Gets the number of columns in the current row.

public int FieldCount { get; }

Property Value

int

IsClosed

Gets a value indicating whether the data reader is closed.

public bool IsClosed { get; }

Property Value

bool

RecordsAffected

Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.

public int RecordsAffected { get; }

Property Value

int

Methods

Close()

Closes the underlying IDataReader.

public void Close()

Dispose()

Releases all resources used by the DataReaderWrapper and the underlying IDataReader.

public void Dispose()

GetBoolean(int)

Gets the value of the specified column as a bool.

public bool GetBoolean(int i)

Parameters

i int

The zero-based column ordinal.

Returns

bool

The value of the column as a bool.

GetByte(int)

Gets the 8-bit unsigned integer value of the specified column.

public byte GetByte(int i)

Parameters

i int

The zero-based column ordinal.

Returns

byte

The 8-bit unsigned integer value of the specified column.

GetBytes(int, long, byte[], int, int)

Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset.

public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, int length)

Parameters

i int

The zero-based column ordinal.

fieldOffset long

The index within the field from which to start the read operation.

buffer byte[]

The buffer into which to read the stream of bytes.

bufferOffset int

The index for buffer to start the read operation.

length int

The number of bytes to read.

Returns

long

The actual number of bytes read.

GetChar(int)

Gets the character value of the specified column.

public char GetChar(int i)

Parameters

i int

The zero-based column ordinal.

Returns

char

The character value of the specified column.

GetChars(int, long, char[], int, int)

Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.

public long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, int length)

Parameters

i int

The zero-based column ordinal.

fieldOffset long

The index within the row from which to start the read operation.

buffer char[]

The buffer into which to read the stream of characters.

bufferOffset int

The index for buffer to start the read operation.

length int

The number of characters to read.

Returns

long

The actual number of characters read.

GetData(int)

Returns an IDataReader for the specified column ordinal.

public IDataReader GetData(int i)

Parameters

i int

The zero-based index of the field.

Returns

IDataReader

An IDataReader for the specified column ordinal.

GetDataTypeName(int)

Gets the data type information for the specified field.

public string GetDataTypeName(int i)

Parameters

i int

The zero-based index of the field.

Returns

string

The data type information for the specified field.

GetDateTime(int)

Gets the date and time data value of the specified field.

public DateTime GetDateTime(int i)

Parameters

i int

The zero-based index of the field.

Returns

DateTime

The date and time data value of the specified field.

GetDecimal(int)

Gets the fixed-position numeric value of the specified field.

public decimal GetDecimal(int i)

Parameters

i int

The zero-based index of the field.

Returns

decimal

The fixed-position numeric value of the specified field.

GetDouble(int)

Gets the double-precision floating point number of the specified field.

public double GetDouble(int i)

Parameters

i int

The zero-based index of the field.

Returns

double

The double-precision floating point number of the specified field.

GetFieldType(int)

Gets the Type information corresponding to the type of object that would be returned from GetValue(int).

public Type GetFieldType(int i)

Parameters

i int

The zero-based index of the field.

Returns

Type

The Type of the field value.

GetFloat(int)

Gets the single-precision floating point number of the specified field.

public float GetFloat(int i)

Parameters

i int

The zero-based index of the field.

Returns

float

The single-precision floating point number of the specified field.

GetGuid(int)

Gets the Guid value of the specified field.

public Guid GetGuid(int i)

Parameters

i int

The zero-based index of the field.

Returns

Guid

The Guid value of the specified field.

GetInt16(int)

Gets the 16-bit signed integer value of the specified field.

public short GetInt16(int i)

Parameters

i int

The zero-based index of the field.

Returns

short

The 16-bit signed integer value of the specified field.

GetInt32(int)

Gets the 32-bit signed integer value of the specified field.

public int GetInt32(int i)

Parameters

i int

The zero-based index of the field.

Returns

int

The 32-bit signed integer value of the specified field.

GetInt64(int)

Gets the 64-bit signed integer value of the specified field.

public long GetInt64(int i)

Parameters

i int

The zero-based index of the field.

Returns

long

The 64-bit signed integer value of the specified field.

GetName(int)

Gets the name of the field at the specified index.

public string GetName(int i)

Parameters

i int

The zero-based index of the field.

Returns

string

The name of the field, or an empty string if there is no value to return.

GetOrdinal(string)

Gets the index of the field with the specified name, applying the field prefix if set.

public int GetOrdinal(string name)

Parameters

name string

The name of the field to find.

Returns

int

The zero-based index of the named field.

GetSchemaTable()

Returns a DataTable that describes the column metadata of the IDataReader.

public DataTable GetSchemaTable()

Returns

DataTable

A DataTable that describes the column metadata.

GetString(int)

Gets the string value of the specified field.

public string GetString(int i)

Parameters

i int

The zero-based index of the field.

Returns

string

The string value of the specified field.

GetValue(int)

Gets the value of the specified field.

public object GetValue(int i)

Parameters

i int

The zero-based index of the field.

Returns

object

The value of the field as an object.

GetValues(object[])

Populates an array of objects with the column values of the current record.

public int GetValues(object[] values)

Parameters

values object[]

An array of object to copy the attribute fields into.

Returns

int

The number of objects in the array.

IsDBNull(int)

Determines whether the specified field is set to null.

public bool IsDBNull(int i)

Parameters

i int

The zero-based index of the field.

Returns

bool

true if the specified field is set to null; otherwise, false.

NextResult()

Advances the data reader to the next result, when reading the results of batch SQL statements.

public bool NextResult()

Returns

bool

true if there are more result sets; otherwise, false.

Read()

Advances the IDataReader to the next record.

public bool Read()

Returns

bool

true if there are more rows; otherwise, false.