📄 gpdatareader.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using FirebirdSql.Data.FirebirdClient;
using System.Data;
using System.Collections;
using System.Data.Common;
using System.ComponentModel;
namespace GPCore
{
/// <summary>
/// A Wrapper for FbDataReader, so Plugins do not have to add a reference
/// to FirebireSQL in order to make SQL queries
/// </summary>
public class GPDataReader : DbDataReader
{
/// <summary>
/// Creates a new GPDataReader
/// </summary>
/// <param name="read">The underlying FBDataReader to wrap.</param>
public GPDataReader(FbDataReader read)
{
this.read = read;
}
private FbDataReader read;
/// <summary>
/// The underlying FbDataReader, if it is deamed necessary.
/// </summary>
public FbDataReader Reader
{
get { return read; }
set { read = value; }
}
/// <summary>
/// Gets the depth of nesting fot the current row.
/// </summary>
/// <value>
/// The depth of nesting for the current row.
/// </value>
/// <remarks>
/// The outmost table has a depth of zero. Ther Firebird .NET Data Provider
/// does not support nesting and always returns zero.
/// </remarks>
public override int Depth { get { return read.Depth; } }
/// <summary>
/// Gets the number of columns in the current row.
/// </summary>
/// <value>
/// When not positioned in a valid recordset, 0; otherwise the number of
/// columns in the current row. The default is -1.
/// </value>
/// <remarks>
/// After executing a query that does not return rows, FieldCount returns 0.
/// </remarks>
public override int FieldCount { get { return read.FieldCount; } }
/// <summary>
/// Gets whether the <see cref="GPDataReader"/> contains one or more rows.
/// </summary>
/// <value>
/// <b>True</b> if the <see cref="GPDataReader"/> contains one or more rows; otherwise false.
/// </value>
/// <remarks>
/// This property returns always <b>true</b>.
/// </remarks>
public override bool HasRows { get { return read.HasRows; } }
/// <summary>
/// Gets a value indicatin whether the data reader is closed.
/// </summary>
/// <value>
/// <b>True</b> if the <see cref="GPDataReader"/> is closed; otherwise false.
/// </value>
/// <remarks>
/// <b>IsClosed</b> and <see cref="RecordsAffected"/> are the only properties that you
/// can call after the <see cref="GPDataReader"/> is closed.
/// </remarks>
public override bool IsClosed { get { return read.IsClosed; } }
/// <summary>
/// Gets the number of rows changed, inserted, or deleted by execution of
/// the DQL statement.
/// </summary>
/// <value>
/// The number of rows changed, inserted, or deleted; o if no rows were affected or the statement
/// failed; and -1 for SELECT statements.
/// </value>
/// <remarks>
/// The value of this property is cumulative, For example, if two records are inserted in batch
/// mode, the value of Records will be two.
/// <see cref ="IsClosed"/> and <b>RecordsAffected</b> are the only properties that you
/// can call after the <see cref="GPDataReader"/> is closed.
/// </remarks>
public override int RecordsAffected { get { return read.RecordsAffected; } }
/// <summary>
/// Gets the number of Fields that are visible from this query.
/// </summary>
public override int VisibleFieldCount { get { return read.VisibleFieldCount; } }
/// <summary>
/// Gets the value of the specified column in its native format given the column ordinal.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>The value of the specified column in its natice format.</returns>
/// <exception cref="IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="FieldCount"/> </exception>
public override object this[int i] { get { return read[i]; } }
/// <summary>
/// Gets the value of the specified column in its native format given the column name.
/// </summary>
/// <param name="name">The column name</param>
/// <returns>The value of the specified column in its native format.</returns>
/// <exception cref="IndexOutOfRangeException">No column with the specified name was found.</exception>
public override object this[string name] { get { return read[name]; } }
/// <summary>
/// Closes the <see cref="GPDataReader"/> object.
/// </summary>
/// <remarks>
/// <para>You must explicity call the <b>Close</b> method when you are using the <see cref="GPDataReader"/> to
/// use the associated FbConnection for any other purpose.
/// </para>
/// <para>
/// The <b>Close</b> method fills in the values for output parameters, return values, increasing the amount of time
/// it takes to close a <b>GPDataReader</b>.
/// </para>
/// </remarks>
public override void Close() { read.Close(); }
/// <summary>
/// Disposes resouces
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing) { base.Dispose(disposing); Close(); }
/// <summary>
/// Gets the value of the specified column as a Boolean.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>A Boolean that is the value of the column.</returns>
/// <remarks>
/// Call IsDBNull to check for null values before calling this method.
/// </remarks>
/// <exception cref="InvalidCastException">The specified cast is not valid.</exception>
public override bool GetBoolean(int i) { return read.GetBoolean(i); }
/// <summary>
/// Gets the value of the specified column as a Byte.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>A Byte that is the value of the column.</returns>
/// <remarks>
/// Call IsDBNull to check for null values before calling this method.
/// </remarks>
/// <exception cref="InvalidCastException">The specified cast is not valid.</exception>
public override byte GetByte(int i) { return read.GetByte(i); }
/// <summary>
/// Reads a stream of bytes from the specified column offset into the buffer as an array,
/// starting at the given buffer offset.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <param name="dataIndex">The index within the field where the read operation is to begin.</param>
/// <param name="buffer">The buffer into which to read the stream of bytes.</param>
/// <param name="bufferIndex">The index where the buffer is to begin the write operation.</param>
/// <param name="length">The number of bytes to read.</param>
/// <returns>The actual number of bytes read.</returns>
/// <remarks>
/// If you pass a buffer that is a null reference, <b>GetBytes</b> returns the length of the field
/// in bytes.
/// No conversions are performed, therefore the data retrived must already be a byte array.
/// </remarks>
public override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length) { return read.GetBytes(i, dataIndex, buffer, bufferIndex, length); }
/// <summary>
/// Gets the value of the specified column as a Char.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>A Char that is the value of the column.</returns>
/// <remarks>
/// Call IsDBNull to check for null values before calling this method.
/// </remarks>
/// <exception cref="InvalidCastException">The specified cast is not valid.</exception>
[EditorBrowsable(EditorBrowsableState.Always)]
public override char GetChar(int i) { return read.GetChar(i); }
/// <summary>
/// Reads a stream of characters from the specified column offset into the buffer as an array,
/// starting at the given buffer offset.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <param name="dataIndex">The index within the field where the read operation is to begin.</param>
/// <param name="buffer">The buffer into which to read the stream of characters.</param>
/// <param name="bufferIndex">The index where the buffer is to begin the write operation.</param>
/// <param name="length">The number of characters to read.</param>
/// <returns>The actual number of characters read.</returns>
/// <remarks>
/// If you pass a buffer that is a null reference, <b>GetChars</b> returns the length of the field
/// in characters.
/// No conversions are performed, therefore the data retrived must already be a character array.
/// </remarks>
public override long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length) { return read.GetChars(i, dataIndex, buffer, bufferIndex, length); }
/// <summary>
/// Gets the name of the source data type.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>The name of the back-end Data Type.</returns>
public override string GetDataTypeName(int i) { return read.GetDataTypeName(i); }
/// <summary>
/// Gets the value of the specified column as a DateTime object.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>A DateTime that is the value of the column.</returns>
/// <remarks>
/// Call IsDBNull to check for null values before calling this method.
/// </remarks>
/// <exception cref="InvalidCastException">The specified cast is not valid.</exception>
public override DateTime GetDateTime(int i) { return read.GetDateTime(i); }
/// <summary>
/// Gets the value of the specified column as a Decimal.
/// </summary>
/// <param name="i">The zero-based column ordinal.</param>
/// <returns>A Decimal that is the value of the column.</returns>
/// <remarks>
/// Call IsDBNull to check for null values before calling this method.
/// </remarks>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -