Search Results for

    Show / Hide Table of Contents

    Class DataConnectionExtensions

    Contains extension methods for DataConnection class.

    Inheritance
    object
    DataConnectionExtensions
    Namespace: LinqToDB.Data
    Assembly: linq2db.dll
    Syntax
    public static class DataConnectionExtensions

    Methods

    | Improve this Doc View Source

    BulkCopy<T>(DataConnection, BulkCopyOptions, IEnumerable<T>)

    Performs bulk insert operation.

    Declaration
    public static BulkCopyRowsCopied BulkCopy<T>(this DataConnection dataConnection, BulkCopyOptions options, IEnumerable<T> source) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    BulkCopyOptions options

    Operation options.

    IEnumerable<T> source

    Records to insert.

    Returns
    Type Description
    BulkCopyRowsCopied

    Bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopy<T>(DataConnection, IEnumerable<T>)

    Performs bulk insert operation.

    Declaration
    public static BulkCopyRowsCopied BulkCopy<T>(this DataConnection dataConnection, IEnumerable<T> source) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    IEnumerable<T> source

    Records to insert.

    Returns
    Type Description
    BulkCopyRowsCopied

    Bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopy<T>(DataConnection, int, IEnumerable<T>)

    Performs bulk insert operation.

    Declaration
    public static BulkCopyRowsCopied BulkCopy<T>(this DataConnection dataConnection, int maxBatchSize, IEnumerable<T> source) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    int maxBatchSize

    Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

    IEnumerable<T> source

    Records to insert.

    Returns
    Type Description
    BulkCopyRowsCopied

    Bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopy<T>(ITable<T>, BulkCopyOptions, IEnumerable<T>)

    Performs bulk insert operation into table specified in options parameter or into table, identified by table.

    Declaration
    public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, BulkCopyOptions options, IEnumerable<T> source) where T : notnull
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    BulkCopyOptions options

    Operation options.

    IEnumerable<T> source

    Records to insert.

    Returns
    Type Description
    BulkCopyRowsCopied

    Bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopy<T>(ITable<T>, IEnumerable<T>)

    Performs bulk insert operation into table, identified by table.

    Declaration
    public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, IEnumerable<T> source) where T : notnull
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    IEnumerable<T> source

    Records to insert.

    Returns
    Type Description
    BulkCopyRowsCopied

    Bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopy<T>(ITable<T>, int, IEnumerable<T>)

    Performs bulk insert operation into table, identified by table.

    Declaration
    public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, int maxBatchSize, IEnumerable<T> source) where T : notnull
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    int maxBatchSize

    Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

    IEnumerable<T> source

    Records to insert.

    Returns
    Type Description
    BulkCopyRowsCopied

    Bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopyAsync<T>(DataConnection, BulkCopyOptions, IEnumerable<T>, CancellationToken)

    Asynchronously performs bulk insert operation.

    Declaration
    public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this DataConnection dataConnection, BulkCopyOptions options, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    BulkCopyOptions options

    Operation options.

    IEnumerable<T> source

    Records to insert.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<BulkCopyRowsCopied>

    Task with bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopyAsync<T>(DataConnection, IEnumerable<T>, CancellationToken)

    Asynchronously performs bulk insert operation.

    Declaration
    public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this DataConnection dataConnection, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    IEnumerable<T> source

    Records to insert.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<BulkCopyRowsCopied>

    Task with bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopyAsync<T>(DataConnection, int, IEnumerable<T>, CancellationToken)

    Asynchronously performs bulk insert operation.

    Declaration
    public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this DataConnection dataConnection, int maxBatchSize, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    int maxBatchSize

    Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

    IEnumerable<T> source

    Records to insert.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<BulkCopyRowsCopied>

    Task with bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopyAsync<T>(ITable<T>, BulkCopyOptions, IEnumerable<T>, CancellationToken)

    Asynchronously performs bulk insert operation into table specified in options parameter or into table, identified by table.

    Declaration
    public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, BulkCopyOptions options, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    BulkCopyOptions options

    Operation options.

    IEnumerable<T> source

    Records to insert.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<BulkCopyRowsCopied>

    Task with bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopyAsync<T>(ITable<T>, IEnumerable<T>, CancellationToken)

    Asynchronously performs bulk insert operation into table, identified by table.

    Declaration
    public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    IEnumerable<T> source

    Records to insert.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<BulkCopyRowsCopied>

    Task with bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    BulkCopyAsync<T>(ITable<T>, int, IEnumerable<T>, CancellationToken)

    Asynchronously performs bulk insert operation into table, identified by table.

    Declaration
    public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, int maxBatchSize, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    int maxBatchSize

    Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

    IEnumerable<T> source

    Records to insert.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<BulkCopyRowsCopied>

    Task with bulk insert operation status.

    Type Parameters
    Name Description
    T

    Mapping type of inserted record.

    | Improve this Doc View Source

    Execute(DataConnection, string, params DataParameter[])

    Executes command and returns number of affected records.

    Declaration
    public static int Execute(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    int

    Number of records, affected by command execution.

    | Improve this Doc View Source

    Execute(DataConnection, string, object?)

    Executes command and returns number of affected records.

    Declaration
    public static int Execute(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    int

    Number of records, affected by command execution.

    | Improve this Doc View Source

    Execute(DataConnection, string)

    Executes command and returns number of affected records.

    Declaration
    public static int Execute(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    int

    Number of records, affected by command execution.

    | Improve this Doc View Source

    Execute<T>(DataConnection, string, DataParameter)

    Executes command and returns single value.

    Declaration
    public static T Execute<T>(this DataConnection connection, string sql, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    T

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    Execute<T>(DataConnection, string, params DataParameter[])

    Executes command and returns single value.

    Declaration
    public static T Execute<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    T

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    Execute<T>(DataConnection, string, object?)

    Executes command and returns single value.

    Declaration
    public static T Execute<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    T

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    Execute<T>(DataConnection, string)

    Executes command and returns single value.

    Declaration
    public static T Execute<T>(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    T

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync(DataConnection, string, params DataParameter[])

    Executes command asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteAsync(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteAsync(DataConnection, string, object?)

    Executes command asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteAsync(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteAsync(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteAsync(DataConnection, string, CancellationToken, object?)

    Executes command asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteAsync(DataConnection, string, CancellationToken)

    Executes command asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteAsync(this DataConnection connection, string sql, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteAsync(DataConnection, string)

    Executes command asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteAsync(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, DataParameter, CancellationToken)

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, DataParameter parameter, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, DataParameter)

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, params DataParameter[])

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, object?)

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, CancellationToken, object?)

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string, CancellationToken)

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteAsync<T>(DataConnection, string)

    Executes command asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteProc(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type and returns number of affected records. Sets result values for output and reference parameters to corresponding parameters in parameters.

    Declaration
    public static int ExecuteProc(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    int

    Number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteProc(DataConnection, string, object?)

    Executes command using StoredProcedure command type and returns number of affected records.

    Declaration
    public static int ExecuteProc(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    int

    Number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteProc<T>(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type and returns single value. Sets result values for output and reference parameters to corresponding parameters in parameters.

    Declaration
    public static T ExecuteProc<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    T

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteProc<T>(DataConnection, string, object?)

    Executes command using StoredProcedure command type and returns single value.

    Declaration
    public static T ExecuteProc<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    T

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteProcAsync(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type asynchronously and returns number of affected records. Sets result values for output and reference parameters to corresponding parameters in parameters.

    Declaration
    public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteProcAsync(DataConnection, string, object?)

    Executes command using StoredProcedure command type asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteProcAsync(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command using StoredProcedure command type asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteProcAsync(DataConnection, string, CancellationToken, object?)

    Executes command using StoredProcedure command type asynchronously and returns number of affected records.

    Declaration
    public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<int>

    Task with number of records, affected by command execution.

    | Improve this Doc View Source

    ExecuteProcAsync<T>(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type asynchronously and returns single value. Sets result values for output and reference parameters to corresponding parameters in parameters.

    Declaration
    public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteProcAsync<T>(DataConnection, string, object?)

    Executes command using StoredProcedure command type asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T>

    Task with resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteProcAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command using StoredProcedure command type asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteProcAsync<T>(DataConnection, string, CancellationToken, object?)

    Executes command using StoredProcedure command type asynchronously and returns single value.

    Declaration
    public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T>

    Resulting value.

    Type Parameters
    Name Description
    T

    Resulting value type.

    | Improve this Doc View Source

    ExecuteReader(DataConnection, string, DataParameter)

    Executes command and returns data reader instance.

    Declaration
    public static DataReader ExecuteReader(this DataConnection connection, string sql, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    DataReader

    Data reader object.

    | Improve this Doc View Source

    ExecuteReader(DataConnection, string, params DataParameter[])

    Executes command and returns data reader instance.

    Declaration
    public static DataReader ExecuteReader(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    DataReader

    Data reader object.

    | Improve this Doc View Source

    ExecuteReader(DataConnection, string, CommandType, CommandBehavior, params DataParameter[])

    Executes command and returns data reader instance.

    Declaration
    public static DataReader ExecuteReader(this DataConnection connection, string sql, CommandType commandType, CommandBehavior commandBehavior, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CommandType commandType

    Type of command. See CommandType for all supported types.

    CommandBehavior commandBehavior

    Command behavior flags. See CommandBehavior for more details.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    DataReader

    Data reader object.

    | Improve this Doc View Source

    ExecuteReader(DataConnection, string, object?)

    Executes command and returns data reader instance.

    Declaration
    public static DataReader ExecuteReader(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    DataReader

    Data reader object.

    | Improve this Doc View Source

    ExecuteReader(DataConnection, string)

    Executes command and returns data reader instance.

    Declaration
    public static DataReader ExecuteReader(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    DataReader

    Data reader object.

    | Improve this Doc View Source

    Merge<T>(DataConnection, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert
    • Delete By Source (optional). If delete operation enabled by delete parameter - method could be used only for with Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this DataConnection dataConnection, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    bool delete

    If true, merge command will include delete by source operation without condition.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(DataConnection, IEnumerable<T>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this DataConnection dataConnection, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(DataConnection, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this DataConnection dataConnection, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    Expression<Func<T, bool>> predicate

    Filter, applied to delete operation. Optional.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(DataConnection, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this DataConnection dataConnection, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    IQueryable<T> source

    Source data to merge into target table. All source data will be loaded from server for command generation.

    Expression<Func<T, bool>> predicate

    Filter, applied both to source and delete operation. Required.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(ITable<T>, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert
    • Delete By Source (optional). If delete operation enabled by delete parameter - method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this ITable<T> table, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    bool delete

    If true, merge command will include delete by source operation without condition.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(ITable<T>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this ITable<T> table, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(ITable<T>, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this ITable<T> table, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    Expression<Func<T, bool>> predicate

    Filter, applied to delete operation. Optional.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Merge<T>(ITable<T>, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions)

    Executes following merge operations in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static int Merge<T>(this ITable<T> table, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    IQueryable<T> source

    Source data to merge into target table. All source data will be loaded from server for command generation.

    Expression<Func<T, bool>> predicate

    Filter, applied both to source and delete operation. Required.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    Returns
    Type Description
    int

    Returns number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(DataConnection, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert
    • Delete By Source (optional). If delete operation enabled by delete parameter - method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this DataConnection dataConnection, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    bool delete

    If true, merge command will include delete by source operation without condition.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(DataConnection, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this DataConnection dataConnection, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(DataConnection, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this DataConnection dataConnection, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    Expression<Func<T, bool>> predicate

    Filter, applied to delete operation. Optional.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(DataConnection, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this DataConnection dataConnection, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    DataConnection dataConnection

    Data connection instance.

    IQueryable<T> source

    Source data to merge into target table. All source data will be loaded from server for command generation.

    Expression<Func<T, bool>> predicate

    Filter, applied both to source and delete operation. Required.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(ITable<T>, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert
    • Delete By Source (optional). If delete operation enabled by delete parameter - method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this ITable<T> table, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    bool delete

    If true, merge command will include delete by source operation without condition.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(ITable<T>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this ITable<T> table, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(ITable<T>, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this ITable<T> table, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    Expression<Func<T, bool>> predicate

    Filter, applied to delete operation. Optional.

    IEnumerable<T> source

    Source data to merge into target table.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    MergeAsync<T>(ITable<T>, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions, CancellationToken)

    Executes following merge operations asynchronously in specified order:

    • Update
    • Insert
    • Delete By Source. Method could be used only with SQL Server.
    Declaration
    [Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
    public static Task<int> MergeAsync<T>(this ITable<T> table, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
    Parameters
    Type Name Description
    ITable<T> table

    Target table.

    IQueryable<T> source

    Source data to merge into target table. All source data will be loaded from server for command generation.

    Expression<Func<T, bool>> predicate

    Filter, applied both to source and delete operation. Required.

    string tableName

    Optional target table name.

    string databaseName

    Optional target table's database name.

    string schemaName

    Optional target table's schema name.

    string serverName

    Optional name of linked server. If not specified, value from mapping will be used.

    TableOptions tableOptions

    Table options. See TableOptions enum for support information per provider.

    CancellationToken cancellationToken

    Optional asynchronous operation cancellation token.

    Returns
    Type Description
    Task<int>

    Task with number of affected target records.

    Type Parameters
    Name Description
    T

    Target table mapping class.

    | Improve this Doc View Source

    Query<T>(DataConnection, T, string, params DataParameter[])

    Executes command and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, T, string, object?)

    Executes command and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, T template, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])

    Executes command and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, Func<DbDataReader, T>, string, object?)

    Executes command and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, Func<DbDataReader, T>, string)

    Executes command and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, string, DataParameter)

    Executes command and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, string sql, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, string, params DataParameter[])

    Executes command and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, string, object?)

    Executes command and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    Query<T>(DataConnection, string)

    Executes command and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> Query<T>(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryMultiple<T>(DataConnection, string, params DataParameter[])

    Executes command and returns a result containing multiple result sets.

    Declaration
    public static T QueryMultiple<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    T

    Returns result.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryMultipleAsync<T>(DataConnection, string, params DataParameter[])

    Executes command asynchronously and returns a result containing multiple result sets.

    Declaration
    public static Task<T> QueryMultipleAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous operation. The task result contains object with multiply result sets.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryMultipleAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns a result containing multiple result sets.

    Declaration
    public static Task<T> QueryMultipleAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous operation. The task result contains object with multiply result sets.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryProc<T>(DataConnection, T, string, params DataParameter[])

    Executes stored procedure and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> QueryProc<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProc<T>(DataConnection, T, string, object?)

    Executes stored procedure and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> QueryProc<T>(this DataConnection connection, T template, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProc<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])

    Executes command using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static IEnumerable<T> QueryProc<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProc<T>(DataConnection, Func<DbDataReader, T>, string, object?)

    Executes command using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static IEnumerable<T> QueryProc<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProc<T>(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> QueryProc<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProc<T>(DataConnection, string, object?)

    Executes command using StoredProcedure command type and returns results as collection of values of specified type.

    Declaration
    public static IEnumerable<T> QueryProc<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    IEnumerable<T>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, T, string, params DataParameter[])

    Executes stored procedure asynchronously and returns results as collection of values of specified type.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, T, string, object?, CancellationToken)

    Executes stored procedure asynchronously and returns results as collection of values of specified type.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, T template, string sql, object? parameters, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, T, string, CancellationToken, params DataParameter[])

    Executes stored procedure asynchronously and returns results as collection of values of specified type.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])

    Executes command asynchronously using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?, CancellationToken)

    Executes command asynchronously using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken, params DataParameter[])

    Executes command asynchronously using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type and returns results as collection of values of specified type.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, string, object?, CancellationToken)

    Executes command asynchronously using StoredProcedure command type and returns results as collection of values of specified type.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, string sql, object? parameters, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command using StoredProcedure command type and returns results as collection of values of specified type.

    Declaration
    public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<IEnumerable<T>>

    Returns collection of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryProcMultiple<T>(DataConnection, string, params DataParameter[])

    Executes command using StoredProcedure command type and returns a result containing multiple result sets. Sets result values for output and reference parameters to corresponding parameters in parameters.

    Declaration
    public static T QueryProcMultiple<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    T

    Returns result.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryProcMultiple<T>(DataConnection, string, object?)

    Executes command using StoredProcedure command type and returns a result containing multiple result sets.

    Declaration
    public static T QueryProcMultiple<T>(this DataConnection connection, string sql, object? parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    T

    Returns result.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryProcMultipleAsync<T>(DataConnection, string, params DataParameter[])

    Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets. Sets result values for output and reference parameters to corresponding parameters in parameters.

    Declaration
    public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous operation. The task result contains object with multiply result sets.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryProcMultipleAsync<T>(DataConnection, string, object?)

    Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets.

    Declaration
    public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, object? parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous operation. The task result contains object with multiply result sets.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryProcMultipleAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets.

    Declaration
    public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous operation. The task result contains object with multiply result sets.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryProcMultipleAsync<T>(DataConnection, string, CancellationToken, object?)

    Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets.

    Declaration
    public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters) where T : class
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text. This is caller's responsibility to properly escape procedure name.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T>

    A task that represents the asynchronous operation. The task result contains object with multiply result sets.

    Type Parameters
    Name Description
    T

    Result set type.

    Remarks
    • type T should have default constructor.

    • if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.

    • if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.

    • if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
    Examples

    Example of T definition with ResultSetIndexAttribute.

    class MultipleResult
    {
       [ResultSetIndex(0)] public IEnumerable<Person>  AllPersons   { get; set; }
       [ResultSetIndex(1)] public IList<Doctor>        AllDoctors   { get; set; }
       [ResultSetIndex(2)] public IEnumerable<Patient> AllPatients  { get; set; }
       [ResultSetIndex(3)] public Patient              FirstPatient { get; set; }
    }

    Example of T definition without attributes.

    class MultipleResult
    {
       public IEnumerable<Person>  AllPersons   { get; set; }
       public IList<Doctor>        AllDoctors   { get; set; }
       public IEnumerable<Patient> AllPatients  { get; set; }
       public Patient              FirstPatient { get; set; }
    }
    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, T, string, params DataParameter[])

    Executes command asynchronously and returns array of values of specified type.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, T, string, object?)

    Executes command asynchronously and returns array of values of specified type.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, T, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns array of values of specified type.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, T, string, CancellationToken, object?)

    Executes command asynchronously and returns array of values of specified type.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])

    Executes command asynchronously and returns array of values, mapped using provided mapping function.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?)

    Executes command asynchronously and returns array of values, mapped using provided mapping function.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns array of values, mapped using provided mapping function.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken, object?)

    Executes command asynchronously and returns array of values, mapped using provided mapping function.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken)

    Executes command asynchronously and returns array of values, mapped using provided mapping function.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string)

    Executes command asynchronously and returns array of values, mapped using provided mapping function.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, DataParameter, CancellationToken)

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, DataParameter parameter, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, DataParameter)

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, params DataParameter[])

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, object?)

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, CancellationToken, object?)

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string, CancellationToken)

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToArrayAsync<T>(DataConnection, string)

    Executes command asynchronously and returns array of values.

    Declaration
    public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    Task<T[]>

    Returns task with array of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, T, string, params DataParameter[])

    Executes command asynchronously and returns list of values of specified type.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, T, string, object?)

    Executes command asynchronously and returns list of values of specified type.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, T, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns list of values of specified type.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, T, string, CancellationToken, object?)

    Executes command asynchronously and returns list of values of specified type.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    T template

    This value used only for T parameter type inference, which makes this method usable with anonymous types.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])

    Executes command asynchronously and returns list of values, mapped using provided mapping function.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?, CancellationToken)

    Executes command asynchronously and returns list of values, mapped using provided mapping function.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?)

    Executes command asynchronously and returns list of values, mapped using provided mapping function.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns list of values, mapped using provided mapping function.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken)

    Executes command asynchronously and returns list of values, mapped using provided mapping function.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string)

    Executes command asynchronously and returns list of values, mapped using provided mapping function.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    Func<DbDataReader, T> objectReader

    Record mapping function from data reader.

    string sql

    Command text.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, DataParameter, CancellationToken)

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, DataParameter parameter, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, DataParameter)

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, params DataParameter[])

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, object?)

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, CancellationToken, object?)

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string, CancellationToken)

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    CancellationToken cancellationToken

    Asynchronous operation cancellation token.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    QueryToListAsync<T>(DataConnection, string)

    Executes command asynchronously and returns list of values.

    Declaration
    public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql)
    Parameters
    Type Name Description
    DataConnection connection

    Database connection.

    string sql

    Command text.

    Returns
    Type Description
    Task<List<T>>

    Returns task with list of query result records.

    Type Parameters
    Name Description
    T

    Result record type.

    | Improve this Doc View Source

    SetCommand(DataConnection, string, DataParameter)

    Creates command wrapper for current connection with provided command text and single parameter.

    Declaration
    public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText, DataParameter parameter)
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    string commandText

    Command text.

    DataParameter parameter

    Command parameter.

    Returns
    Type Description
    CommandInfo

    Database command wrapper.

    | Improve this Doc View Source

    SetCommand(DataConnection, string, params DataParameter[])

    Creates command wrapper for current connection with provided command text and parameters.

    Declaration
    public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText, params DataParameter[] parameters)
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    string commandText

    Command text.

    DataParameter[] parameters

    Command parameters.

    Returns
    Type Description
    CommandInfo

    Database command wrapper.

    | Improve this Doc View Source

    SetCommand(DataConnection, string, object?)

    Creates command wrapper for current connection with provided command text and parameters.

    Declaration
    public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText, object? parameters)
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    string commandText

    Command text.

    object parameters

    Command parameters. Supported values:

    - null for command without parameters;

    - single DataParameter instance;

    - array of DataParameter parameters;

    - mapping class entity.

    Last case will convert all mapped columns to DataParameter instances using following logic:

    - if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;

    - if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;

    - otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.

    Returns
    Type Description
    CommandInfo

    Database command wrapper.

    | Improve this Doc View Source

    SetCommand(DataConnection, string)

    Creates command wrapper for current connection with provided command text.

    Declaration
    public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText)
    Parameters
    Type Name Description
    DataConnection dataConnection

    Database connection.

    string commandText

    Command text.

    Returns
    Type Description
    CommandInfo

    Database command wrapper.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2011-2023 linq2db.com

    Generated by DocFX