Class DuckDbDataReader
ADO.NET-compatible reader for the results of a query in DuckDB.
Inherited Members
Namespace: Mallard.Ado
Assembly: Mallard.dll
Syntax
public sealed class DuckDbDataReader : DbDataReader, IEnumerable, IDataReader, IDataRecord, IDisposable, IAsyncDisposable
Properties
| Edit this page View SourceDepth
Gets a value indicating the depth of nesting for the current row.
Declaration
public override int Depth { get; }
Property Value
Type | Description |
---|---|
int | The depth of nesting for the current row. |
Overrides
| Edit this page View SourceFieldCount
When overridden in a derived class, gets the number of columns in the current row.
Declaration
public override int FieldCount { get; }
Property Value
Type | Description |
---|---|
int | The number of columns in the current row. |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | There is no current connection to an instance of SQL Server. |
HasRows
When overridden in a derived class, gets a value that indicates whether this DbDataReader contains one or more rows.
Declaration
public override bool HasRows { get; }
Property Value
Type | Description |
---|---|
bool | true if the DbDataReader contains one or more rows; otherwise, false. |
Overrides
| Edit this page View SourceIsClosed
When overridden in a derived class, gets a value indicating whether the DbDataReader is closed.
Declaration
public override bool IsClosed { get; }
Property Value
Type | Description |
---|---|
bool | true if the DbDataReader is closed; otherwise, false. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The DbDataReader is closed. |
this[int]
When overridden in a derived class, gets the value of the specified column as an instance of object.
Declaration
public override object this[int ordinal] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Property Value
Type | Description |
---|---|
object | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
this[string]
When overridden in a derived class, gets the value of the specified column as an instance of object.
Declaration
public override object this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the column. |
Property Value
Type | Description |
---|---|
object | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | No column with the specified name was found. |
RecordsAffected
When overridden in a derived class, gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
Declaration
public override int RecordsAffected { get; }
Property Value
Type | Description |
---|---|
int | The number of rows changed, inserted, or deleted. -1 for SELECT statements; 0 if no rows were affected or the statement failed. |
Overrides
Methods
| Edit this page View SourceClose()
Closes the DbDataReader object.
Declaration
public override void Close()
Overrides
| Edit this page View SourceGetBoolean(int)
When overridden in a derived class, gets the value of the specified column as a Boolean.
Declaration
public override bool GetBoolean(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
bool | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetByte(int)
When overridden in a derived class, gets the value of the specified column as a byte.
Declaration
public override byte GetByte(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
byte | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetBytes(int, long, byte[]?, int, int)
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.
Declaration
public override long GetBytes(int ordinal, long dataOffset, byte[]? buffer, int bufferOffset, int length)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
long | dataOffset | The index within the row from which to begin the read operation. |
byte[] | buffer | The buffer into which to copy the data. |
int | bufferOffset | The index with the buffer to which the data will be copied. |
int | length | The maximum number of bytes to read. |
Returns
Type | Description |
---|---|
long | The actual number of bytes read. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetChar(int)
When overridden in a derived class, gets the value of the specified column as a single character.
Declaration
public override char GetChar(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
char | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetChars(int, long, char[]?, int, int)
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.
Declaration
public override long GetChars(int ordinal, long dataOffset, char[]? buffer, int bufferOffset, int length)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
long | dataOffset | The index within the row from which to begin the read operation. |
char[] | buffer | The buffer into which to copy the data. |
int | bufferOffset | The index with the buffer to which the data will be copied. |
int | length | The maximum number of characters to read. |
Returns
Type | Description |
---|---|
long | The actual number of characters read. |
Overrides
| Edit this page View SourceGetDataTypeName(int)
When overridden in a derived class, gets name of the data type of the specified column.
Declaration
public override string GetDataTypeName(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
string | The name of the data type. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
GetDateTime(int)
When overridden in a derived class, gets the value of the specified column as a DateTime object.
Declaration
public override DateTime GetDateTime(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
DateTime | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetDecimal(int)
When overridden in a derived class, gets the value of the specified column as a decimal.
Declaration
public override decimal GetDecimal(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
decimal | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetDouble(int)
When overridden in a derived class, gets the value of the specified column as a double-precision floating point number.
Declaration
public override double GetDouble(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
double | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidCastException | The specified cast is not valid. |
GetEnumerator()
When overridden in a derived class, returns an enumerator that can be used to iterate through the rows in the data reader.
Declaration
public override IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | An enumerator that can be used to iterate through the rows in the data reader. |
Overrides
GetFieldType(int)
When overridden in a derived class, gets the data type of the specified column.
Declaration
public override Type GetFieldType(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
Type | The data type of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetFieldValue<T>(int)
Gets the value of the specified column as the requested type.
Declaration
public override T GetFieldValue<T>(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
T | The value of the specified column. |
Type Parameters
Name | Description |
---|---|
T | The type of the value to be returned. |
Overrides
Exceptions
Type | Condition |
---|---|
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 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 |
GetFloat(int)
When overridden in a derived class, gets the value of the specified column as a single-precision floating point number.
Declaration
public override float GetFloat(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
float | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetGuid(int)
When overridden in a derived class, gets the value of the specified column as a globally unique identifier (GUID).
Declaration
public override Guid GetGuid(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
Guid | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetInt16(int)
When overridden in a derived class, gets the value of the specified column as a 16-bit signed integer.
Declaration
public override short GetInt16(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
short | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetInt32(int)
When overridden in a derived class, gets the value of the specified column as a 32-bit signed integer.
Declaration
public override int GetInt32(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
int | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetInt64(int)
When overridden in a derived class, gets the value of the specified column as a 64-bit signed integer.
Declaration
public override long GetInt64(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
long | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetName(int)
When overridden in a derived class, gets the name of the column, given the zero-based column ordinal.
Declaration
public override string GetName(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
string | The name of the specified column. |
Overrides
| Edit this page View SourceGetOrdinal(string)
When overridden in a derived class, gets the column ordinal given the name of the column.
Declaration
public override int GetOrdinal(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the column. |
Returns
Type | Description |
---|---|
int | The zero-based column ordinal. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The name specified is not a valid column name. |
GetSchemaTable()
Returns a DataTable that describes the result columns.
Declaration
public override DataTable GetSchemaTable()
Returns
Type | Description |
---|---|
DataTable | A DataTable with the columns: |
Overrides
Remarks
Implementations of this method in other ADO.NET providers re-query the database to obtain detailed information on the columns such as key constraints. Doing the same is difficult in DuckDB's C API, so this implementation provides basic information only.
The returned instance is created anew by this method and is not cached.
GetStream(int)
Gets a stream to retrieve data from the specified column.
Declaration
public override Stream GetStream(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
Stream | A stream. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The connection was dropped or closed during the data retrieval. -or- The data reader is closed during the data retrieval. -or- There is no data ready to be read (for example, the first Read() hasn't been called, or returned false). -or- The data 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 specified column isn't a binary type that supports reading with a Stream. |
GetString(int)
When overridden in a derived class, gets the value of the specified column as an instance of string.
Declaration
public override string GetString(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
string | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
InvalidCastException | The specified cast is not valid. |
GetTextReader(int)
Gets a text reader to retrieve data from the column.
Declaration
public override TextReader GetTextReader(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
TextReader | A text reader. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The connection was dropped or closed during the data retrieval. -or- The data reader is closed during the data retrieval. -or- There is no data ready to be read (for example, the first Read() hasn't been called, or returned false). -or- The data 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 specified column isn't a text type that supports reading with a TextReader. |
GetValue(int)
When overridden in a derived class, gets the value of the specified column as an instance of object.
Declaration
public override object GetValue(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
object | The value of the specified column. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
GetValues(object[])
When overridden in a derived class, populates an array of objects with the column values of the current row.
Declaration
public override int GetValues(object[] values)
Parameters
Type | Name | Description |
---|---|---|
object[] | values | An array of object into which to copy the attribute columns. |
Returns
Type | Description |
---|---|
int | The number of instances of object in the array. |
Overrides
| Edit this page View SourceIsDBNull(int)
When overridden in a derived class, gets a value that indicates whether the column contains nonexistent or missing values.
Declaration
public override bool IsDBNull(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
int | ordinal | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
bool | true if the specified column is equivalent to DBNull; otherwise, false. |
Overrides
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The column index is out of range. |
NextResult()
When overridden in a derived class, advances the reader to the next result when reading the results of a batch of statements.
Declaration
public override bool NextResult()
Returns
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceRead()
When overridden in a derived class, advances the reader to the next record in a result set.
Declaration
public override bool Read()
Returns
Type | Description |
---|---|
bool |