Table of Contents

Class DataContextExtensions

Namespace
LinqToDB.Data
Assembly
linq2db.dll

Contains extension methods for DataConnection and DataContext classes.

public static class DataContextExtensions
Inheritance
DataContextExtensions
Inherited Members

Methods

BulkCopyAsync<T>(IDataContext, BulkCopyOptions, IAsyncEnumerable<T>, CancellationToken)

Asynchronously performs bulk insert operation.

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this IDataContext dataContext, BulkCopyOptions options, IAsyncEnumerable<T> source, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

options BulkCopyOptions

Operation options.

source IAsyncEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Asynchronously performs bulk insert operation.

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this IDataContext dataContext, BulkCopyOptions options, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

options BulkCopyOptions

Operation options.

source IEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

BulkCopyAsync<T>(IDataContext, IAsyncEnumerable<T>, CancellationToken)

Asynchronously performs bulk insert operation.

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this IDataContext dataContext, IAsyncEnumerable<T> source, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

source IAsyncEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Asynchronously performs bulk insert operation.

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this IDataContext dataContext, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

source IEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

BulkCopyAsync<T>(IDataContext, int, IAsyncEnumerable<T>, CancellationToken)

Asynchronously performs bulk insert operation.

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this IDataContext dataContext, int maxBatchSize, IAsyncEnumerable<T> source, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

maxBatchSize int

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

source IAsyncEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Asynchronously performs bulk insert operation.

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this IDataContext dataContext, int maxBatchSize, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

maxBatchSize int

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

source IEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

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

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, BulkCopyOptions options, IAsyncEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull

Parameters

table ITable<T>

Target table.

options BulkCopyOptions

Operation options.

source IAsyncEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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.

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

Parameters

table ITable<T>

Target table.

options BulkCopyOptions

Operation options.

source IEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

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

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, IAsyncEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull

Parameters

table ITable<T>

Target table.

source IAsyncEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

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

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

Parameters

table ITable<T>

Target table.

source IEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

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

public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, int maxBatchSize, IAsyncEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull

Parameters

table ITable<T>

Target table.

maxBatchSize int

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

source IAsyncEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

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

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

Parameters

table ITable<T>

Target table.

maxBatchSize int

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

source IEnumerable<T>

Records to insert.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<BulkCopyRowsCopied>

Task with bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Performs bulk insert operation.

public static BulkCopyRowsCopied BulkCopy<T>(this IDataContext dataContext, BulkCopyOptions options, IEnumerable<T> source) where T : class

Parameters

dataContext IDataContext

Database connection.

options BulkCopyOptions

Operation options.

source IEnumerable<T>

Records to insert.

Returns

BulkCopyRowsCopied

Bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Performs bulk insert operation.

public static BulkCopyRowsCopied BulkCopy<T>(this IDataContext dataContext, IEnumerable<T> source) where T : class

Parameters

dataContext IDataContext

Database connection.

source IEnumerable<T>

Records to insert.

Returns

BulkCopyRowsCopied

Bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Performs bulk insert operation.

public static BulkCopyRowsCopied BulkCopy<T>(this IDataContext dataContext, int maxBatchSize, IEnumerable<T> source) where T : class

Parameters

dataContext IDataContext

Database connection.

maxBatchSize int

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

source IEnumerable<T>

Records to insert.

Returns

BulkCopyRowsCopied

Bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

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

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

Parameters

table ITable<T>

Target table.

options BulkCopyOptions

Operation options.

source IEnumerable<T>

Records to insert.

Returns

BulkCopyRowsCopied

Bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Performs bulk insert operation into table, identified by table.

public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, IEnumerable<T> source) where T : notnull

Parameters

table ITable<T>

Target table.

source IEnumerable<T>

Records to insert.

Returns

BulkCopyRowsCopied

Bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

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

Performs bulk insert operation into table, identified by table.

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

Parameters

table ITable<T>

Target table.

maxBatchSize int

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

source IEnumerable<T>

Records to insert.

Returns

BulkCopyRowsCopied

Bulk insert operation status.

Type Parameters

T

Mapping type of inserted record.

Execute(IDataContext, string)

Executes command and returns number of affected records.

public static int Execute(this IDataContext dataContext, string sql)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

Returns

int

Number of records, affected by command execution.

Execute(IDataContext, string, params DataParameter[])

Executes command and returns number of affected records.

public static int Execute(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

int

Number of records, affected by command execution.

Execute(IDataContext, string, object?)

Executes command and returns number of affected records.

public static int Execute(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

int

Number of records, affected by command execution.

ExecuteAsync(IDataContext, string, params DataParameter[])

Executes command asynchronously and returns number of affected records.

public static Task<int> ExecuteAsync(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<int>

Task with number of records, affected by command execution.

ExecuteAsync(IDataContext, string, object?, CancellationToken)

Executes command asynchronously and returns number of affected records.

public static Task<int> ExecuteAsync(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<int>

Task with number of records, affected by command execution.

ExecuteAsync(IDataContext, string, CancellationToken)

Executes command asynchronously and returns number of affected records.

public static Task<int> ExecuteAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<int>

Task with number of records, affected by command execution.

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

Executes command asynchronously and returns number of affected records.

public static Task<int> ExecuteAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<int>

Task with number of records, affected by command execution.

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

Executes command asynchronously and returns single value.

public static Task<T> ExecuteAsync<T>(this IDataContext dataContext, string sql, DataParameter parameter, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<T>

Task with resulting value.

Type Parameters

T

Resulting value type.

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

Executes command asynchronously and returns single value.

public static Task<T> ExecuteAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<T>

Task with resulting value.

Type Parameters

T

Resulting value type.

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

Executes command asynchronously and returns single value.

public static Task<T> ExecuteAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<T>

Task with resulting value.

Type Parameters

T

Resulting value type.

ExecuteAsync<T>(IDataContext, string, CancellationToken)

Executes command asynchronously and returns single value.

public static Task<T> ExecuteAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<T>

Task with resulting value.

Type Parameters

T

Resulting value type.

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

Executes command asynchronously and returns single value.

public static Task<T> ExecuteAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T>

Task with resulting value.

Type Parameters

T

Resulting value type.

ExecuteProc(IDataContext, 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.

public static int ExecuteProc(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

int

Number of records, affected by command execution.

ExecuteProc(IDataContext, string, object?)

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

public static int ExecuteProc(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

int

Number of records, affected by command execution.

ExecuteProcAsync(IDataContext, 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.

public static Task<int> ExecuteProcAsync(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

Task<int>

Task with number of records, affected by command execution.

ExecuteProcAsync(IDataContext, string, object?, CancellationToken)

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

public static Task<int> ExecuteProcAsync(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

Task<int>

Task with number of records, affected by command execution.

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

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

public static Task<int> ExecuteProcAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<int>

Task with number of records, affected by command execution.

ExecuteProcAsync<T>(IDataContext, 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.

public static Task<T> ExecuteProcAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

Task<T>

Task with resulting value.

Type Parameters

T

Resulting value type.

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

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

public static Task<T> ExecuteProcAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

Task<T>

Resulting value.

Type Parameters

T

Resulting value type.

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

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

public static Task<T> ExecuteProcAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T>

Resulting value.

Type Parameters

T

Resulting value type.

ExecuteProc<T>(IDataContext, 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.

public static T ExecuteProc<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

T

Resulting value.

Type Parameters

T

Resulting value type.

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

Executes command using StoredProcedure command type and returns single value.

public static T ExecuteProc<T>(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

T

Resulting value.

Type Parameters

T

Resulting value type.

ExecuteReader(IDataContext, string)

Executes command and returns data reader instance.

public static DataReaderAsync ExecuteReader(this IDataContext dataContext, string sql)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

Returns

DataReaderAsync

Data reader object.

ExecuteReader(IDataContext, string, DataParameter)

Executes command and returns data reader instance.

public static DataReaderAsync ExecuteReader(this IDataContext dataContext, string sql, DataParameter parameter)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

Returns

DataReaderAsync

Data reader object.

ExecuteReader(IDataContext, string, params DataParameter[])

Executes command and returns data reader instance.

public static DataReaderAsync ExecuteReader(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

DataReaderAsync

Data reader object.

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

Executes command and returns data reader instance.

public static DataReaderAsync ExecuteReader(this IDataContext dataContext, string sql, CommandType commandType, CommandBehavior commandBehavior, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

commandType CommandType

Type of command. See CommandType for all supported types.

commandBehavior CommandBehavior

Command behavior flags. See CommandBehavior for more details.

parameters DataParameter[]

Command parameters.

Returns

DataReaderAsync

Data reader object.

ExecuteReader(IDataContext, string, object?)

Executes command and returns data reader instance.

public static DataReaderAsync ExecuteReader(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

DataReaderAsync

Data reader object.

ExecuteReaderAsync(IDataContext, string, DataParameter, CancellationToken)

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, DataParameter parameter, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderAsync(IDataContext, string, params DataParameter[])

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderAsync(IDataContext, string, CommandType, CommandBehavior, params DataParameter[])

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, CommandType commandType, CommandBehavior commandBehavior, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

commandType CommandType

Type of command. See CommandType for all supported types.

commandBehavior CommandBehavior

Command behavior flags. See CommandBehavior for more details.

parameters DataParameter[]

Command parameters.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderAsync(IDataContext, string, CommandType, CommandBehavior, CancellationToken, params DataParameter[])

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, CommandType commandType, CommandBehavior commandBehavior, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

commandType CommandType

Type of command. See CommandType for all supported types.

commandBehavior CommandBehavior

Command behavior flags. See CommandBehavior for more details.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderAsync(IDataContext, string, object?, CancellationToken)

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<DataReaderAsync>

Data reader object.

ExecuteReaderAsync(IDataContext, string, CancellationToken)

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderAsync(IDataContext, string, CancellationToken, params DataParameter[])

Executes command and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderProc(IDataContext, string, params DataParameter[])

Executes command using StoredProcedure command type and returns data reader instance.

public static DataReaderAsync ExecuteReaderProc(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

DataReaderAsync

Data reader object.

ExecuteReaderProc(IDataContext, string, object?)

Executes command using StoredProcedure command type and returns data reader instance.

public static DataReaderAsync ExecuteReaderProc(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

DataReaderAsync

Data reader object.

ExecuteReaderProcAsync(IDataContext, string, params DataParameter[])

Executes command using StoredProcedure command type and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderProcAsync(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<DataReaderAsync>

Data reader object.

ExecuteReaderProcAsync(IDataContext, string, object?, CancellationToken)

Executes command using StoredProcedure command type and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderProcAsync(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<DataReaderAsync>

Data reader object.

ExecuteReaderProcAsync(IDataContext, string, CancellationToken, params DataParameter[])

Executes command using StoredProcedure command type and returns data reader instance.

public static Task<DataReaderAsync> ExecuteReaderProcAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<DataReaderAsync>

Data reader object.

Execute<T>(IDataContext, string)

Executes command and returns single value.

public static T Execute<T>(this IDataContext dataContext, string sql)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

Returns

T

Resulting value.

Type Parameters

T

Resulting value type.

Execute<T>(IDataContext, string, DataParameter)

Executes command and returns single value.

public static T Execute<T>(this IDataContext dataContext, string sql, DataParameter parameter)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

Returns

T

Resulting value.

Type Parameters

T

Resulting value type.

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

Executes command and returns single value.

public static T Execute<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

T

Resulting value.

Type Parameters

T

Resulting value type.

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

Executes command and returns single value.

public static T Execute<T>(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

T

Resulting value.

Type Parameters

T

Resulting value type.

QueryAsync<T>(IDataContext, Func<DbDataReader, T>, string, params DataParameter[])

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, Func<DbDataReader, T>, string, object?, CancellationToken)

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters object

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

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, Func<DbDataReader, T>, string, CancellationToken)

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, Func<DbDataReader, T>, string, CancellationToken, params DataParameter[])

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, string, DataParameter, CancellationToken)

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, string sql, DataParameter parameter, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, string, params DataParameter[])

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, string, object?, CancellationToken)

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, string, CancellationToken)

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, string, CancellationToken, params DataParameter[])

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, T, string, params DataParameter[])

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, T, string, object?, CancellationToken)

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, T template, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryAsync<T>(IDataContext, T, string, CancellationToken, params DataParameter[])

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

public static Task<IEnumerable<T>> QueryAsync<T>(this IDataContext dataContext, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T> QueryMultipleAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<T>

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

Type Parameters

T

Result set type.

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; }
}

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.

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

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

public static Task<T> QueryMultipleAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T>

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

Type Parameters

T

Result set type.

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; }
}

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.

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

Executes command and returns a result containing multiple result sets.

public static T QueryMultiple<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

T

Returns result.

Type Parameters

T

Result set type.

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; }
}

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.

QueryProcAsync<T>(IDataContext, 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.

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryProcAsync<T>(IDataContext, 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.

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

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

parameters object

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

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryProcAsync<T>(IDataContext, 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.

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

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

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, T template, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<IEnumerable<T>> QueryProcAsync<T>(this IDataContext dataContext, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<IEnumerable<T>>

Returns collection of query result records.

Type Parameters

T

Result record type.

QueryProcMultipleAsync<T>(IDataContext, 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.

public static Task<T> QueryProcMultipleAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

Task<T>

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

Type Parameters

T

Result set type.

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; }
}

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.

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

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

public static Task<T> QueryProcMultipleAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

Task<T>

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

Type Parameters

T

Result set type.

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; }
}

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.

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

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

public static Task<T> QueryProcMultipleAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

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

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T>

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

Type Parameters

T

Result set type.

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; }
}

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.

QueryProcMultiple<T>(IDataContext, 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.

public static T QueryProcMultiple<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

T

Returns result.

Type Parameters

T

Result set type.

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; }
}

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.

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

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

public static T QueryProcMultiple<T>(this IDataContext dataContext, string sql, object? parameters) where T : class

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

T

Returns result.

Type Parameters

T

Result set type.

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; }
}

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.

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

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

public static IEnumerable<T> QueryProc<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> QueryProc<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

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

parameters object

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

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> QueryProc<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters DataParameter[]

Command parameters.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> QueryProc<T>(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

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

parameters object

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

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> QueryProc<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> QueryProc<T>(this IDataContext dataContext, T template, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters object

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

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns array of values.

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, string sql, DataParameter parameter, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns array of values.

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns array of values.

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

QueryToArrayAsync<T>(IDataContext, string, CancellationToken)

Executes command asynchronously and returns array of values.

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns array of values.

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, T template, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<T[]> QueryToArrayAsync<T>(this IDataContext dataContext, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<T[]>

Returns task with array of query result records.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, Func<DbDataReader, T>, string)

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

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

Returns

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, Func<DbDataReader, T>, string, params DataParameter[])

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

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, Func<DbDataReader, T>, string, object?)

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

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters object

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

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, string)

Executes command asynchronously and returns array of values.

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, string sql)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

Returns

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, string, DataParameter)

Executes command asynchronously and returns array of values.

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, string sql, DataParameter parameter)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

Returns

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, string, params DataParameter[])

Executes command asynchronously and returns array of values.

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, string, object?)

Executes command asynchronously and returns array of values.

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, T, string, params DataParameter[])

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

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

QueryToAsyncEnumerable<T>(IDataContext, T, string, object?)

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

public static IAsyncEnumerable<T> QueryToAsyncEnumerable<T>(this IDataContext dataContext, T template, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

IAsyncEnumerable<T>

Async sequence of records returned by the query.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters object

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

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns list of values.

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, string sql, DataParameter parameter, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns list of values.

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns list of values.

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

QueryToListAsync<T>(IDataContext, string, CancellationToken)

Executes command asynchronously and returns list of values.

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

Executes command asynchronously and returns list of values.

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, T template, string sql, object? parameters, CancellationToken cancellationToken = default)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static Task<List<T>> QueryToListAsync<T>(this IDataContext dataContext, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

parameters DataParameter[]

Command parameters.

Returns

Task<List<T>>

Returns task with list of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, Func<DbDataReader, T> objectReader, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

objectReader Func<DbDataReader, T>

Record mapping function from data reader.

sql string

Command text.

parameters object

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

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

Query<T>(IDataContext, string)

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, string sql)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

Query<T>(IDataContext, string, DataParameter)

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, string sql, DataParameter parameter)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameter DataParameter

Command parameter.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

sql string

Command text.

parameters object

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

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, T template, string sql, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters DataParameter[]

Command parameters.

Returns

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

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

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

public static IEnumerable<T> Query<T>(this IDataContext dataContext, T template, string sql, object? parameters)

Parameters

dataContext IDataContext

Database connection.

template T

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

sql string

Command text.

parameters object

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

IEnumerable<T>

Returns collection of query result records.

Type Parameters

T

Result record type.

SetCommand(IDataContext, string)

Creates command wrapper for current connection with provided command text.

public static CommandInfo SetCommand(this IDataContext dataContext, string commandText)

Parameters

dataContext IDataContext

Database connection.

commandText string

Command text.

Returns

CommandInfo

Database command wrapper.

SetCommand(IDataContext, string, DataParameter)

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

public static CommandInfo SetCommand(this IDataContext dataContext, string commandText, DataParameter parameter)

Parameters

dataContext IDataContext

Database connection.

commandText string

Command text.

parameter DataParameter

Command parameter.

Returns

CommandInfo

Database command wrapper.

SetCommand(IDataContext, string, params DataParameter[])

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

public static CommandInfo SetCommand(this IDataContext dataContext, string commandText, params DataParameter[] parameters)

Parameters

dataContext IDataContext

Database connection.

commandText string

Command text.

parameters DataParameter[]

Command parameters.

Returns

CommandInfo

Database command wrapper.

SetCommand(IDataContext, string, object?)

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

public static CommandInfo SetCommand(this IDataContext dataContext, string commandText, object? parameters)

Parameters

dataContext IDataContext

Database connection.

commandText string

Command text.

parameters object

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

CommandInfo

Database command wrapper.