Class DataReader<TRead>
Provides a generic way of reading a forward-only stream of rows from a TRead based data source. This is an abstract class.
public abstract class DataReader<TRead> : Disposable, IDataReader, IDataRecord, IDisposable
Type Parameters
TReadThe type of the value that this IDataReader will read.
- Inheritance
-
DataReader<TRead>
- Implements
- Derived
- Inherited Members
Constructors
DataReader()
Initializes a new instance of the DataReader<TRead> class.
protected DataReader()
Properties
Depth
Gets a value indicating the depth of nesting for the current row.
public virtual int Depth { get; }
Property Value
- int
The level of nesting.
FieldCount
Gets the number of columns in the current row.
public int FieldCount { get; }
Property Value
- int
When not positioned in a valid recordset, 0; otherwise, the number of columns in the current record.
this[int]
Gets the column located at the specified index.
public object this[int i] { get; }
Parameters
iintThe zero-based index of the column to get.
Property Value
this[string]
Gets the column with the specified name.
public object this[string name] { get; }
Parameters
namestringThe name of the column to find.
Property Value
NullRead
Gets the value that indicates that no more rows exists.
protected abstract TRead NullRead { get; }
Property Value
- TRead
The value that indicates that no more rows exists.
RowCount
Gets the currently processed row count of this instance.
public abstract int RowCount { get; protected set; }
Property Value
- int
The currently processed row count of this instance.
Methods
Contains(string)
Determines whether this instance contains a column with the specified name.
public bool Contains(string name)
Parameters
namestringThe name of the column to find.
Returns
- bool
trueif this instance contains a column with the specified name; otherwise,false.
GetBoolean(int)
Gets the value of the specified column as a Boolean.
public bool GetBoolean(int i)
Parameters
iintThe zero-based column ordinal.
Returns
- bool
The value of the column.
GetByte(int)
Gets the 8-bit unsigned integer value of the specified column.
public byte GetByte(int i)
Parameters
iintThe 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, starting at location indicated by dataOffset, into the buffer, starting at the location indicated by bufferOffset.
public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
Parameters
iintThe zero-based column ordinal.
fieldOffsetlongThe index within the row from which to begin the read operation.
bufferbyte[]The buffer into which to copy the data.
bufferoffsetintThe index with the buffer to which the data will be copied.
lengthintThe maximum number of characters 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
iintThe zero-based column ordinal.
Returns
- char
The character value of the specified column.
GetDateTime(int)
Gets the date and time data value of the specified field.
public DateTime GetDateTime(int i)
Parameters
iintThe index of the field to find.
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
iintThe index of the field to find.
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
iintThe index of the field to find.
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
iintThe index of the field to find.
Returns
- Type
The Type information corresponding to the type of Object that would be returned from GetValue(int).
GetFloat(int)
Gets the single-precision floating point number of the specified field.
public float GetFloat(int i)
Parameters
iintThe index of the field to find.
Returns
- float
The single-precision floating point number of the specified field.
GetGuid(int)
Returns the GUID value of the specified field.
public Guid GetGuid(int i)
Parameters
iintThe index of the field to find.
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
iintThe index of the field to find.
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
iintThe index of the field to find.
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
iintThe index of the field to find.
Returns
- long
The 64-bit signed integer value of the specified field.
GetName(int)
Gets the name for the field to find.
public string GetName(int i)
Parameters
iintThe index of the field to find.
Returns
- string
The name of the field or the empty string (""), if there is no value to return.
GetOrdinal(string)
Return the index of the named field.
public int GetOrdinal(string name)
Parameters
namestringThe name of the field to find.
Returns
- int
The index of the named field.
Exceptions
- ArgumentNullException
nameis null.- ArgumentOutOfRangeException
nameis not a valid column name.
GetString(int)
Gets the string value of the specified field.
public string GetString(int i)
Parameters
iintThe index of the field to find.
Returns
- string
The string value of the specified field.
GetValue(int)
Return the value of the specified field.
public object GetValue(int i)
Parameters
iintThe index of the field to find.
Returns
GetValues(object[])
Populates an array of objects with the column values of the current record.
public int GetValues(object[] values)
Parameters
Returns
IsDBNull(int)
Return whether the specified field is set to null.
public bool IsDBNull(int i)
Parameters
iintThe index of the field to find.
Returns
- bool
true if the specified field is set to null; otherwise, false.
Read()
Advances the IDataReader to the next record.
public abstract bool Read()
Returns
ReadNext(TRead)
Advances the IDataReader to the next record.
protected abstract TRead ReadNext(TRead columns)
Parameters
columnsTRead
Returns
- TRead
TReadfor as long as there are rows; NullRead when no more rows exists.
SetFields(IOrderedDictionary)
Sets the fields of the current record invoked by ReadNext(TRead).
protected void SetFields(IOrderedDictionary fields)
Parameters
fieldsIOrderedDictionaryThe fields of the current record invoked by ReadNext(TRead).
ToString()
Returns a string that represents the current row of this instance.
public override string ToString()