Class DataContextExtensions
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
dataContextIDataContextDatabase connection.
optionsBulkCopyOptionsOperation options.
sourceIAsyncEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
optionsBulkCopyOptionsOperation options.
sourceIEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
sourceIAsyncEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
sourceIEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
maxBatchSizeintNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
sourceIAsyncEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
maxBatchSizeintNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
sourceIEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
optionsBulkCopyOptionsOperation options.
sourceIAsyncEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
optionsBulkCopyOptionsOperation options.
sourceIEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
sourceIAsyncEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
sourceIEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
maxBatchSizeintNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
sourceIAsyncEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
maxBatchSizeintNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
sourceIEnumerable<T>Records to insert.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
optionsBulkCopyOptionsOperation options.
sourceIEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
sourceIEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
maxBatchSizeintNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
sourceIEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
optionsBulkCopyOptionsOperation options.
sourceIEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
sourceIEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
TMapping 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
tableITable<T>Target table.
maxBatchSizeintNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
sourceIEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection.
sqlstringCommand 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
Task with resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
Task with resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
Task with resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
Task with resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
Task with resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
Task with resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
Resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
Resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- T
Resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResulting value type.
ExecuteReader(IDataContext, string)
Executes command and returns data reader instance.
public static DataReaderAsync ExecuteReader(this IDataContext dataContext, string sql)
Parameters
dataContextIDataContextDatabase connection.
sqlstringCommand 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
commandTypeCommandTypeType of command. See CommandType for all supported types.
commandBehaviorCommandBehaviorCommand behavior flags. See CommandBehavior for more details.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
cancellationTokenCancellationTokenAsynchronous 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
commandTypeCommandTypeType of command. See CommandType for all supported types.
commandBehaviorCommandBehaviorCommand behavior flags. See CommandBehavior for more details.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
commandTypeCommandTypeType of command. See CommandType for all supported types.
commandBehaviorCommandBehaviorCommand behavior flags. See CommandBehavior for more details.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
Returns
- T
Resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
Returns
- T
Resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- T
Resulting value.
Type Parameters
TResulting 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResulting 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- T
Returns result.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- T
Returns result.
Type Parameters
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
Tshould 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersDataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text. This is caller's responsibility to properly escape procedure name.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
Returns
- IAsyncEnumerable<T>
Async sequence of records returned by the query.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IAsyncEnumerable<T>
Async sequence of records returned by the query.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
Returns
- IAsyncEnumerable<T>
Async sequence of records returned by the query.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
Returns
- IAsyncEnumerable<T>
Async sequence of records returned by the query.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IAsyncEnumerable<T>
Async sequence of records returned by the query.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IAsyncEnumerable<T>
Async sequence of records returned by the query.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
parametersDataParameter[]Command parameters.
Returns
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
objectReaderFunc<DbDataReader, T>Record mapping function from data reader.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parameterDataParameterCommand parameter.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersDataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
TResult 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
dataContextIDataContextDatabase connection.
templateTThis value used only for
Tparameter type inference, which makes this method usable with anonymous types.sqlstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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
TResult 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
dataContextIDataContextDatabase connection.
commandTextstringCommand 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
dataContextIDataContextDatabase connection.
commandTextstringCommand text.
parameterDataParameterCommand 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
dataContextIDataContextDatabase connection.
commandTextstringCommand text.
parametersDataParameter[]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
dataContextIDataContextDatabase connection.
commandTextstringCommand text.
parametersobjectCommand parameters. Supported values:
-
nullfor 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.