Class DataConnectionExtensions
Contains extension methods for DataConnection class.
public static class DataConnectionExtensions
- Inheritance
-
DataConnectionExtensions
Methods
BulkCopyAsync<T>(DataConnection, BulkCopyOptions, IEnumerable<T>, CancellationToken)
Asynchronously performs bulk insert operation.
public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this DataConnection dataConnection, BulkCopyOptions options, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionDatabase connection.
options
BulkCopyOptionsOperation options.
source
IEnumerable<T>Records to insert.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopyAsync<T>(DataConnection, IEnumerable<T>, CancellationToken)
Asynchronously performs bulk insert operation.
public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this DataConnection dataConnection, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionDatabase connection.
source
IEnumerable<T>Records to insert.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopyAsync<T>(DataConnection, int, IEnumerable<T>, CancellationToken)
Asynchronously performs bulk insert operation.
public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this DataConnection dataConnection, int maxBatchSize, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionDatabase connection.
maxBatchSize
intNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
source
IEnumerable<T>Records to insert.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopyAsync<T>(ITable<T>, BulkCopyOptions, IEnumerable<T>, CancellationToken)
Asynchronously performs bulk insert operation into table specified in options
parameter or into table, identified by table
.
public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, BulkCopyOptions options, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull
Parameters
table
ITable<T>Target table.
options
BulkCopyOptionsOperation options.
source
IEnumerable<T>Records to insert.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopyAsync<T>(ITable<T>, IEnumerable<T>, CancellationToken)
Asynchronously performs bulk insert operation into table, identified by table
.
public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull
Parameters
table
ITable<T>Target table.
source
IEnumerable<T>Records to insert.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopyAsync<T>(ITable<T>, int, IEnumerable<T>, CancellationToken)
Asynchronously performs bulk insert operation into table, identified by table
.
public static Task<BulkCopyRowsCopied> BulkCopyAsync<T>(this ITable<T> table, int maxBatchSize, IEnumerable<T> source, CancellationToken cancellationToken = default) where T : notnull
Parameters
table
ITable<T>Target table.
maxBatchSize
intNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
source
IEnumerable<T>Records to insert.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<BulkCopyRowsCopied>
Task with bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopy<T>(DataConnection, BulkCopyOptions, IEnumerable<T>)
Performs bulk insert operation.
public static BulkCopyRowsCopied BulkCopy<T>(this DataConnection dataConnection, BulkCopyOptions options, IEnumerable<T> source) where T : class
Parameters
dataConnection
DataConnectionDatabase connection.
options
BulkCopyOptionsOperation options.
source
IEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopy<T>(DataConnection, IEnumerable<T>)
Performs bulk insert operation.
public static BulkCopyRowsCopied BulkCopy<T>(this DataConnection dataConnection, IEnumerable<T> source) where T : class
Parameters
dataConnection
DataConnectionDatabase connection.
source
IEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopy<T>(DataConnection, int, IEnumerable<T>)
Performs bulk insert operation.
public static BulkCopyRowsCopied BulkCopy<T>(this DataConnection dataConnection, int maxBatchSize, IEnumerable<T> source) where T : class
Parameters
dataConnection
DataConnectionDatabase connection.
maxBatchSize
intNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
source
IEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopy<T>(ITable<T>, BulkCopyOptions, IEnumerable<T>)
Performs bulk insert operation into table specified in options
parameter or into table, identified by table
.
public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, BulkCopyOptions options, IEnumerable<T> source) where T : notnull
Parameters
table
ITable<T>Target table.
options
BulkCopyOptionsOperation options.
source
IEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopy<T>(ITable<T>, IEnumerable<T>)
Performs bulk insert operation into table, identified by table
.
public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, IEnumerable<T> source) where T : notnull
Parameters
table
ITable<T>Target table.
source
IEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
BulkCopy<T>(ITable<T>, int, IEnumerable<T>)
Performs bulk insert operation into table, identified by table
.
public static BulkCopyRowsCopied BulkCopy<T>(this ITable<T> table, int maxBatchSize, IEnumerable<T> source) where T : notnull
Parameters
table
ITable<T>Target table.
maxBatchSize
intNumber of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
source
IEnumerable<T>Records to insert.
Returns
- BulkCopyRowsCopied
Bulk insert operation status.
Type Parameters
T
Mapping type of inserted record.
Execute(DataConnection, string)
Executes command and returns number of affected records.
public static int Execute(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
- int
Number of records, affected by command execution.
Execute(DataConnection, string, params DataParameter[])
Executes command and returns number of affected records.
public static int Execute(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- int
Number of records, affected by command execution.
Execute(DataConnection, string, object?)
Executes command and returns number of affected records.
public static int Execute(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- int
Number of records, affected by command execution.
ExecuteAsync(DataConnection, string)
Executes command asynchronously and returns number of affected records.
public static Task<int> ExecuteAsync(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
ExecuteAsync(DataConnection, string, params DataParameter[])
Executes command asynchronously and returns number of affected records.
public static Task<int> ExecuteAsync(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
ExecuteAsync(DataConnection, string, object?)
Executes command asynchronously and returns number of affected records.
public static Task<int> ExecuteAsync(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
ExecuteAsync(DataConnection, string, CancellationToken)
Executes command asynchronously and returns number of affected records.
public static Task<int> ExecuteAsync(this DataConnection connection, string sql, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
ExecuteAsync(DataConnection, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns number of affected records.
public static Task<int> ExecuteAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
ExecuteAsync(DataConnection, string, CancellationToken, object?)
Executes command asynchronously and returns number of affected records.
public static Task<int> ExecuteAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
ExecuteAsync<T>(DataConnection, string)
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, DataParameter)
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, DataParameter parameter)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, DataParameter, CancellationToken)
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, DataParameter parameter, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, params DataParameter[])
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, object?)
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, CancellationToken)
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteAsync<T>(DataConnection, string, CancellationToken, object?)
Executes command asynchronously and returns single value.
public static Task<T> ExecuteAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteProc(DataConnection, string, params DataParameter[])
Executes command using StoredProcedure command type and returns number of affected records.
Sets result values for output and reference parameters to corresponding parameters in parameters
.
public static int ExecuteProc(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- int
Number of records, affected by command execution.
ExecuteProc(DataConnection, string, object?)
Executes command using StoredProcedure command type and returns number of affected records.
public static int ExecuteProc(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- int
Number of records, affected by command execution.
ExecuteProcAsync(DataConnection, string, params DataParameter[])
Executes command using StoredProcedure command type asynchronously and returns number of affected records.
Sets result values for output and reference parameters to corresponding parameters in parameters
.
public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
ExecuteProcAsync(DataConnection, string, object?)
Executes command using StoredProcedure command type asynchronously and returns number of affected records.
public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
ExecuteProcAsync(DataConnection, string, CancellationToken, params DataParameter[])
Executes command using StoredProcedure command type asynchronously and returns number of affected records.
public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
ExecuteProcAsync(DataConnection, string, CancellationToken, object?)
Executes command using StoredProcedure command type asynchronously and returns number of affected records.
public static Task<int> ExecuteProcAsync(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
ExecuteProcAsync<T>(DataConnection, string, params DataParameter[])
Executes command using StoredProcedure command type asynchronously and returns single value.
Sets result values for output and reference parameters to corresponding parameters in parameters
.
public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteProcAsync<T>(DataConnection, string, object?)
Executes command using StoredProcedure command type asynchronously and returns single value.
public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T>
Task with resulting value.
Type Parameters
T
Resulting value type.
ExecuteProcAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])
Executes command using StoredProcedure command type asynchronously and returns single value.
public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
Resulting value.
Type Parameters
T
Resulting value type.
ExecuteProcAsync<T>(DataConnection, string, CancellationToken, object?)
Executes command using StoredProcedure command type asynchronously and returns single value.
public static Task<T> ExecuteProcAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T>
Resulting value.
Type Parameters
T
Resulting value type.
ExecuteProc<T>(DataConnection, string, params DataParameter[])
Executes command using StoredProcedure command type and returns single value.
Sets result values for output and reference parameters to corresponding parameters in parameters
.
public static T ExecuteProc<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- T
Resulting value.
Type Parameters
T
Resulting value type.
ExecuteProc<T>(DataConnection, string, object?)
Executes command using StoredProcedure command type and returns single value.
public static T ExecuteProc<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- T
Resulting value.
Type Parameters
T
Resulting value type.
ExecuteReader(DataConnection, string)
Executes command and returns data reader instance.
public static DataReader ExecuteReader(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
- DataReader
Data reader object.
ExecuteReader(DataConnection, string, DataParameter)
Executes command and returns data reader instance.
public static DataReader ExecuteReader(this DataConnection connection, string sql, DataParameter parameter)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
- DataReader
Data reader object.
ExecuteReader(DataConnection, string, params DataParameter[])
Executes command and returns data reader instance.
public static DataReader ExecuteReader(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- DataReader
Data reader object.
ExecuteReader(DataConnection, string, CommandType, CommandBehavior, params DataParameter[])
Executes command and returns data reader instance.
public static DataReader ExecuteReader(this DataConnection connection, string sql, CommandType commandType, CommandBehavior commandBehavior, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
commandType
CommandTypeType of command. See CommandType for all supported types.
commandBehavior
CommandBehaviorCommand behavior flags. See CommandBehavior for more details.
parameters
DataParameter[]Command parameters.
Returns
- DataReader
Data reader object.
ExecuteReader(DataConnection, string, object?)
Executes command and returns data reader instance.
public static DataReader ExecuteReader(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- DataReader
Data reader object.
Execute<T>(DataConnection, string)
Executes command and returns single value.
public static T Execute<T>(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
- T
Resulting value.
Type Parameters
T
Resulting value type.
Execute<T>(DataConnection, string, DataParameter)
Executes command and returns single value.
public static T Execute<T>(this DataConnection connection, string sql, DataParameter parameter)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
- T
Resulting value.
Type Parameters
T
Resulting value type.
Execute<T>(DataConnection, string, params DataParameter[])
Executes command and returns single value.
public static T Execute<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- T
Resulting value.
Type Parameters
T
Resulting value type.
Execute<T>(DataConnection, string, object?)
Executes command and returns single value.
public static T Execute<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- T
Resulting value.
Type Parameters
T
Resulting value type.
MergeAsync<T>(DataConnection, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
delete
parameter - method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
delete
boolIf true, merge command will include delete by source operation without condition.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(DataConnection, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(DataConnection, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
predicate
Expression<Func<T, bool>>Filter, applied to delete operation. Optional.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(DataConnection, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
source
IQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicate
Expression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(ITable<T>, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
delete
parameter - method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this ITable<T> table, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
table
ITable<T>Target table.
delete
boolIf true, merge command will include delete by source operation without condition.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(ITable<T>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this ITable<T> table, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
table
ITable<T>Target table.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(ITable<T>, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this ITable<T> table, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
table
ITable<T>Target table.
predicate
Expression<Func<T, bool>>Filter, applied to delete operation. Optional.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
MergeAsync<T>(ITable<T>, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static Task<int> MergeAsync<T>(this ITable<T> table, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
table
ITable<T>Target table.
source
IQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicate
Expression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
cancellationToken
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table mapping class.
Merge<T>(DataConnection, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
delete
parameter - method could be used only for with Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this DataConnection dataConnection, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
delete
boolIf true, merge command will include delete by source operation without condition.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(DataConnection, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this DataConnection dataConnection, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(DataConnection, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this DataConnection dataConnection, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
predicate
Expression<Func<T, bool>>Filter, applied to delete operation. Optional.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(DataConnection, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this DataConnection dataConnection, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnection
DataConnectionData connection instance.
source
IQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicate
Expression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(ITable<T>, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
delete
parameter - method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this ITable<T> table, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
table
ITable<T>Target table.
delete
boolIf true, merge command will include delete by source operation without condition.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(ITable<T>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this ITable<T> table, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
table
ITable<T>Target table.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(ITable<T>, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this ITable<T> table, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
table
ITable<T>Target table.
predicate
Expression<Func<T, bool>>Filter, applied to delete operation. Optional.
source
IEnumerable<T>Source data to merge into target table.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
Merge<T>(ITable<T>, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
[Obsolete("Legacy Merge API obsoleted and will be removed in future versions. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/DataConnectionExtensions.LegacyMerge.cs.")]
public static int Merge<T>(this ITable<T> table, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
table
ITable<T>Target table.
source
IQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicate
Expression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableName
stringOptional target table name.
databaseName
stringOptional target table's database name.
schemaName
stringOptional target table's schema name.
serverName
stringOptional name of linked server. If not specified, value from mapping will be used.
tableOptions
TableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
T
Target table mapping class.
QueryMultipleAsync<T>(DataConnection, string, params DataParameter[])
Executes command asynchronously and returns a result containing multiple result sets.
public static Task<T> QueryMultipleAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryMultipleAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns a result containing multiple result sets.
public static Task<T> QueryMultipleAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryMultiple<T>(DataConnection, string, params DataParameter[])
Executes command and returns a result containing multiple result sets.
public static T QueryMultiple<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- T
Returns result.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProcAsync<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])
Executes command asynchronously using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.
public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?, CancellationToken)
Executes command asynchronously using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.
public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken = default)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken, params DataParameter[])
Executes command asynchronously using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.
public static Task<IEnumerable<T>> QueryProcAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, 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 DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, 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 DataConnection connection, string sql, object? parameters, CancellationToken cancellationToken = default)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, 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 DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, 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 DataConnection connection, T template, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, 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 DataConnection connection, T template, string sql, object? parameters, CancellationToken cancellationToken = default)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcAsync<T>(DataConnection, 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 DataConnection connection, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<IEnumerable<T>>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProcMultipleAsync<T>(DataConnection, string, params DataParameter[])
Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets.
Sets result values for output and reference parameters to corresponding parameters in parameters
.
public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProcMultipleAsync<T>(DataConnection, string, object?)
Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets.
public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, object? parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProcMultipleAsync<T>(DataConnection, 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 DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProcMultipleAsync<T>(DataConnection, string, CancellationToken, object?)
Executes command asynchronously using StoredProcedure command type and returns a result containing multiple result sets.
public static Task<T> QueryProcMultipleAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T>
A task that represents the asynchronous operation. The task result contains object with multiply result sets.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProcMultiple<T>(DataConnection, string, params DataParameter[])
Executes command using StoredProcedure command type and returns a result containing multiple result sets.
Sets result values for output and reference parameters to corresponding parameters in parameters
.
public static T QueryProcMultiple<T>(this DataConnection connection, string sql, params DataParameter[] parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- T
Returns result.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProcMultiple<T>(DataConnection, string, object?)
Executes command using StoredProcedure command type and returns a result containing multiple result sets.
public static T QueryProcMultiple<T>(this DataConnection connection, string sql, object? parameters) where T : class
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- T
Returns result.
Type Parameters
T
Result set type.
Examples
Example of T
definition with ResultSetIndexAttribute.
class MultipleResult
{
[ResultSetIndex(0)] public IEnumerable<Person> AllPersons { get; set; }
[ResultSetIndex(1)] public IList<Doctor> AllDoctors { get; set; }
[ResultSetIndex(2)] public IEnumerable<Patient> AllPatients { get; set; }
[ResultSetIndex(3)] public Patient FirstPatient { get; set; }
}
Example of T
definition without attributes.
class MultipleResult
{
public IEnumerable<Person> AllPersons { get; set; }
public IList<Doctor> AllDoctors { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
public Patient FirstPatient { get; set; }
}
Remarks
- type
T
should have default constructor. - if at least one property or field has ResultSetIndexAttribute, then properties that are not marked with ResultSetIndexAttribute will be ignored.
- if there is missing index in properties that are marked with ResultSetIndexAttribute, then result set under missing index will be ignored.
- if there is no ResultSetIndexAttribute, then all non readonly fields or properties with setter will read from multiple result set. Order is based on their appearance in class.
QueryProc<T>(DataConnection, Func<DbDataReader, T>, string, params DataParameter[])
Executes command using StoredProcedure command type and returns results as collection of values, mapped using provided mapping function.
public static IEnumerable<T> QueryProc<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProc<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProc<T>(DataConnection, 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 DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
DataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProc<T>(DataConnection, 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 DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text. This is caller's responsibility to properly escape procedure name.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProc<T>(DataConnection, T, string, params DataParameter[])
Executes stored procedure and returns results as collection of values of specified type.
public static IEnumerable<T> QueryProc<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryProc<T>(DataConnection, T, string, object?)
Executes stored procedure and returns results as collection of values of specified type.
public static IEnumerable<T> QueryProc<T>(this DataConnection connection, T template, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string)
Executes command asynchronously and returns array of values, mapped using provided mapping function.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?)
Executes command asynchronously and returns array of values, mapped using provided mapping function.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, Func<DbDataReader, T>, string, CancellationToken, object?)
Executes command asynchronously and returns array of values, mapped using provided mapping function.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string)
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, DataParameter)
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, DataParameter parameter)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, DataParameter, CancellationToken)
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, DataParameter parameter, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, params DataParameter[])
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, object?)
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, CancellationToken)
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, string, CancellationToken, object?)
Executes command asynchronously and returns array of values.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, T, string, params DataParameter[])
Executes command asynchronously and returns array of values of specified type.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, T, string, object?)
Executes command asynchronously and returns array of values of specified type.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, T, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns array of values of specified type.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToArrayAsync<T>(DataConnection, T, string, CancellationToken, object?)
Executes command asynchronously and returns array of values of specified type.
public static Task<T[]> QueryToArrayAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- Task<T[]>
Returns task with array of query result records.
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string)
Executes command asynchronously and returns list of values, mapped using provided mapping function.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, Func<DbDataReader, T>, string, object?)
Executes command asynchronously and returns list of values, mapped using provided mapping function.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string)
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, DataParameter)
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, DataParameter parameter)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, DataParameter, CancellationToken)
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, DataParameter parameter, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, params DataParameter[])
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, object?)
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, CancellationToken)
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, string, CancellationToken, object?)
Executes command asynchronously and returns list of values.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, T, string, params DataParameter[])
Executes command asynchronously and returns list of values of specified type.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, T, string, object?)
Executes command asynchronously and returns list of values of specified type.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, T, string, CancellationToken, params DataParameter[])
Executes command asynchronously and returns list of values of specified type.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
DataParameter[]Command parameters.
Returns
Type Parameters
T
Result record type.
QueryToListAsync<T>(DataConnection, T, string, CancellationToken, object?)
Executes command asynchronously and returns list of values of specified type.
public static Task<List<T>> QueryToListAsync<T>(this DataConnection connection, T template, string sql, CancellationToken cancellationToken, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
Type Parameters
T
Result record type.
Query<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, 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 DataConnection connection, Func<DbDataReader, T> objectReader, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
objectReader
Func<DbDataReader, T>Record mapping function from data reader.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, string)
Executes command and returns results as collection of values of specified type.
public static IEnumerable<T> Query<T>(this DataConnection connection, string sql)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, string, DataParameter)
Executes command and returns results as collection of values of specified type.
public static IEnumerable<T> Query<T>(this DataConnection connection, string sql, DataParameter parameter)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, string, params DataParameter[])
Executes command and returns results as collection of values of specified type.
public static IEnumerable<T> Query<T>(this DataConnection connection, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, string, object?)
Executes command and returns results as collection of values of specified type.
public static IEnumerable<T> Query<T>(this DataConnection connection, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, T, string, params DataParameter[])
Executes command and returns results as collection of values of specified type.
public static IEnumerable<T> Query<T>(this DataConnection connection, T template, string sql, params DataParameter[] parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
Query<T>(DataConnection, T, string, object?)
Executes command and returns results as collection of values of specified type.
public static IEnumerable<T> Query<T>(this DataConnection connection, T template, string sql, object? parameters)
Parameters
connection
DataConnectionDatabase connection.
template
TThis value used only for
T
parameter type inference, which makes this method usable with anonymous types.sql
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- IEnumerable<T>
Returns collection of query result records.
Type Parameters
T
Result record type.
SetCommand(DataConnection, string)
Creates command wrapper for current connection with provided command text.
public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText)
Parameters
dataConnection
DataConnectionDatabase connection.
commandText
stringCommand text.
Returns
- CommandInfo
Database command wrapper.
SetCommand(DataConnection, string, DataParameter)
Creates command wrapper for current connection with provided command text and single parameter.
public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText, DataParameter parameter)
Parameters
dataConnection
DataConnectionDatabase connection.
commandText
stringCommand text.
parameter
DataParameterCommand parameter.
Returns
- CommandInfo
Database command wrapper.
SetCommand(DataConnection, string, params DataParameter[])
Creates command wrapper for current connection with provided command text and parameters.
public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText, params DataParameter[] parameters)
Parameters
dataConnection
DataConnectionDatabase connection.
commandText
stringCommand text.
parameters
DataParameter[]Command parameters.
Returns
- CommandInfo
Database command wrapper.
SetCommand(DataConnection, string, object?)
Creates command wrapper for current connection with provided command text and parameters.
public static CommandInfo SetCommand(this DataConnection dataConnection, string commandText, object? parameters)
Parameters
dataConnection
DataConnectionDatabase connection.
commandText
stringCommand text.
parameters
objectCommand parameters. Supported values:
-
null
for command without parameters;- single DataParameter instance;
- array of DataParameter parameters;
- mapping class entity.
Last case will convert all mapped columns to DataParameter instances using following logic:
- if column is of DataParameter type, column value will be used. If parameter name (Name) is not set, column name will be used;
- if converter from column type to DataParameter is defined in mapping schema, it will be used to create parameter with column name passed to converter;
- otherwise column value will be converted to DataParameter using column name as parameter name and column value will be converted to parameter value using conversion, defined by mapping schema.
Returns
- CommandInfo
Database command wrapper.