Search Results for

    Show / Hide Table of Contents

    Class AdbCommand

    An Adb command with an SQL statement or stored procedure and parameters to execute against a data source, similar to a DbCommand, with extra information and functionality. It is created by the AdbCommandBuilder Create() method or by AdbConnection CreateCommand(String) overloads.

    Information about the data source and the provider can be found via the Connection property.

    The command must be disposed after use. See Disposing Disposables for details.

    Inheritance
    Object
    AdbCommand
    Implements
    IDisposable
    Namespace: actionETL.Adb
    Assembly: actionETL.dll
    Syntax
    public sealed class AdbCommand : IDisposable
    Remarks

    Do design database workers to take AdbConnectionString, IAdbConnectionBuilder, and AdbCommandBuilder instances as parameters, which allows them to support connections with different AdbConnectionMode. Conversely, avoid passing AdbConnection, AdbKeepOpenConnection, AdbCommand, or connection (text) strings to workers.

    Properties

    CommandText

    Gets or sets the command text to execute.

    Declaration
    public string CommandText { get; set; }
    Property Value
    Type Description
    String

    CommandTimeout

    Gets or sets the command timeout, in seconds.

    Declaration
    public int CommandTimeout { get; set; }
    Property Value
    Type Description
    Int32

    CommandType

    Gets or sets the command type.

    Declaration
    public CommandType CommandType { get; set; }
    Property Value
    Type Description
    CommandType

    Default is Text.

    Connection

    Gets the Adb database connection.

    Declaration
    public IAdbConnection Connection { get; }
    Property Value
    Type Description
    IAdbConnection

    Parameters

    Gets the Adb parameter collection, for creating, adding and inspecting the command database parameters.

    Declaration
    public AdbParameterCollection Parameters { get; }
    Property Value
    Type Description
    AdbParameterCollection

    Transaction

    Gets or sets an AdbTransaction within which this command will execute. Setting the transaction is only needed if the transaction was not active when this command was created (which automatically picks up any active transaction).

    Declaration
    public AdbTransaction Transaction { get; set; }
    Property Value
    Type Description
    AdbTransaction

    The transaction, or null if there is no transaction present.

    UnderlyingCommand

    Gets the underlying .NET DbCommand.

    Note: Always use the members on AdbCommand, where available. In rare cases however, the underlying .NET DbCommand is needed, e.g. when accessing provider-specific functionality not covered by AdbCommand.

    Declaration
    public DbCommand UnderlyingCommand { get; }
    Property Value
    Type Description
    DbCommand

    Methods

    Cancel()

    Cancels the command if possible.

    Declaration
    public void Cancel()

    Dispose()

    Dispose the instance. If this command 'owns' (i.e. it created) the associated connection, also dispose the connection.

    Declaration
    public void Dispose()

    ExecuteNonQuery()

    Executes CommandText against the Connection as a synchronous non-query, i.e. without returning a result set. Any output parameters and return values are however populated with data.

    Declaration
    public int ExecuteNonQuery()
    Returns
    Type Description
    Int32

    The number of rows affected.

    Exceptions
    Type Condition
    Exception

    (See the provider documentation for specific exceptions.)

    ExecuteNonQueryAsync()

    Executes CommandText against the Connection as an asynchronous non-query, i.e. without returning a result set. Any output parameters and return values are however populated with data.

    Declaration
    public Task<int> ExecuteNonQueryAsync()
    Returns
    Type Description
    Task<Int32>

    A Task{int} that completes when the query completes, with the number of rows affected. The task will contain any exceptions raised (see the provider documentation for specific exceptions).

    ExecuteReader()

    Executes CommandText against the Connection as a synchronous query. The result set is available to read from the returned DbDataReader.

    Declaration
    public DbDataReader ExecuteReader()
    Returns
    Type Description
    DbDataReader

    A DbDataReader to read the result set from.

    Exceptions
    Type Condition
    Exception

    (See the provider documentation for specific exceptions.)

    ExecuteReader(CommandBehavior)

    Executes CommandText against the Connection as a synchronous query. The result set is available to read from the returned DbDataReader.

    Declaration
    public DbDataReader ExecuteReader(CommandBehavior commandBehavior)
    Parameters
    Type Name Description
    CommandBehavior commandBehavior

    The command behavior.

    Returns
    Type Description
    DbDataReader

    A DbDataReader to read the result set from.

    Exceptions
    Type Condition
    Exception

    (See the provider documentation for specific exceptions.)

    ExecuteReaderAsync()

    Executes CommandText against the Connection as an asynchronous query. The result set is available to read from the returned DbDataReader.

    Declaration
    public Task<DbDataReader> ExecuteReaderAsync()
    Returns
    Type Description
    Task<DbDataReader>

    A Task{DbDataReader} that completes when the query completes, with the DbDataReader to read the result set from. The task will contain any exceptions raised (see the provider documentation for specific exceptions).

    ExecuteReaderAsync(CommandBehavior)

    Executes CommandText against the Connection as an asynchronous query. The result set is available to read from the returned DbDataReader.

    Declaration
    public Task<DbDataReader> ExecuteReaderAsync(CommandBehavior commandBehavior)
    Parameters
    Type Name Description
    CommandBehavior commandBehavior

    The command behavior.

    Returns
    Type Description
    Task<DbDataReader>

    A Task{DbDataReader} that completes when the query completes, with the DbDataReader to read the result set from. The task will contain any exceptions raised (see the provider documentation for specific exceptions).

    ExecuteScalar()

    Executes CommandText against the Connection as a synchronous query.

    Declaration
    public object ExecuteScalar()
    Returns
    Type Description
    Object

    The first column of the first row in the result set returned by the query. All other columns and rows are ignored.

    Exceptions
    Type Condition
    Exception

    (See the provider documentation for specific exceptions.)

    ExecuteScalarAsync()

    Executes CommandText against the Connection as an asynchronous query.

    Declaration
    public Task<object> ExecuteScalarAsync()
    Returns
    Type Description
    Task<Object>

    A Task{object} that completes when the query completes, with the first column of the first row in the result set returned by the query. All other columns and rows are ignored. The task will contain any exceptions raised (see the provider documentation for specific exceptions).

    Prepare()

    Creates a prepared (or compiled) version of the command on the data source.

    Declaration
    public void Prepare()

    Implements

    System.IDisposable

    See Also

    AdbCommandBuilder
    IAdbConnection
    IAdbConnectionBuilder
    AdbConnectionBuilder
    AdbKeepOpenConnectionBuilder
    DbCommand
    In This Article
    • Properties
      • CommandText
      • CommandTimeout
      • CommandType
      • Connection
      • Parameters
      • Transaction
      • UnderlyingCommand
    • Methods
      • Cancel()
      • Dispose()
      • ExecuteNonQuery()
      • ExecuteNonQueryAsync()
      • ExecuteReader()
      • ExecuteReader(CommandBehavior)
      • ExecuteReaderAsync()
      • ExecuteReaderAsync(CommandBehavior)
      • ExecuteScalar()
      • ExecuteScalarAsync()
      • Prepare()
    • Implements
    • See Also
    Back to top Copyright © 2023 Envobi Ltd