Skip to main content

SqlMapper

Dapper, a light weight object mapper for ADO.NET

Assembly: ServiceStack.OrmLite.dll​
View Source​
Declaration
public static class SqlMapper : object

Properties​

ConnectionStringComparer​

How should connection strings be compared for equivalence? Defaults to StringComparer.Ordinal. Providing a custom implementation can be useful for allowing multi-tenancy databases with identical schema to share strategies. Note that usual equivalence rules apply: any equivalent connection strings <strong>MUST</strong> yield the same hash-code.

View Source​
Declaration
public static IEqualityComparer<string> ConnectionStringComparer { get; set; }

Fields​

TypeMapProvider​

Gets type-map for the given type

View Source​
Declaration
public static Func<Type, SqlMapper.ITypeMap> TypeMapProvider

Methods​

QueryAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a query asynchronously using Task.

Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static Task<IEnumerable<dynamic>> QueryAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<System.Object>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.String | sql | The SQL to execute for the query. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Object | param | The parameters to pass, if any. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | IDbTransaction | transaction | The transaction to use, if any. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds). Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<CommandType> | commandType | The type of command to execute. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QueryAsync(IDbConnection, CommandDefinition)​

Execute a query asynchronously using Task.

Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static Task<IEnumerable<dynamic>> QueryAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<IEnumerable<System.Object>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QueryFirstAsync(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static Task<dynamic> QueryFirstAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QueryFirstOrDefaultAsync(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static Task<dynamic> QueryFirstOrDefaultAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QuerySingleAsync(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static Task<dynamic> QuerySingleAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QuerySingleOrDefaultAsync(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static Task<dynamic> QuerySingleOrDefaultAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QueryAsync<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a query asynchronously using Task.

View Source​
Declaration
public static Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<T>>>: A sequence of data of <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of results to return.

QueryFirstAsync<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QueryFirstAsync<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

QueryFirstOrDefaultAsync<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QueryFirstOrDefaultAsync<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

QuerySingleAsync<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QuerySingleAsync<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

QuerySingleOrDefaultAsync<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QuerySingleOrDefaultAsync<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type to return.

QueryFirstAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<dynamic> QueryFirstAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryFirstOrDefaultAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<dynamic> QueryFirstOrDefaultAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QuerySingleAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<dynamic> QuerySingleAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QuerySingleOrDefaultAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<dynamic> QuerySingleOrDefaultAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryAsync(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a query asynchronously using Task.

View Source​
Declaration
public static Task<IEnumerable<object>> QueryAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<System.Object>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryFirstAsync(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QueryFirstAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryFirstOrDefaultAsync(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QueryFirstOrDefaultAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QuerySingleAsync(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QuerySingleAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QuerySingleOrDefaultAsync(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QuerySingleOrDefaultAsync(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryAsync<T>(IDbConnection, CommandDefinition)​

Execute a query asynchronously using Task.

View Source​
Declaration
public static Task<IEnumerable<T>> QueryAsync<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<IEnumerable<<T>>>: A sequence of data of <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type to return.

QueryAsync(IDbConnection, Type, CommandDefinition)​

Execute a query asynchronously using Task.

View Source​
Declaration
public static Task<IEnumerable<object>> QueryAsync(this IDbConnection cnn, Type type, CommandDefinition command)
Returns​

Task<IEnumerable<System.Object>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

QueryFirstAsync(IDbConnection, Type, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QueryFirstAsync(this IDbConnection cnn, Type type, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

QueryFirstAsync<T>(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QueryFirstAsync<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type to return.

QueryFirstOrDefaultAsync(IDbConnection, Type, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QueryFirstOrDefaultAsync(this IDbConnection cnn, Type type, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

QueryFirstOrDefaultAsync<T>(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QueryFirstOrDefaultAsync<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type to return.

QuerySingleAsync(IDbConnection, Type, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QuerySingleAsync(this IDbConnection cnn, Type type, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

QuerySingleAsync<T>(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QuerySingleAsync<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type to return.

QuerySingleOrDefaultAsync(IDbConnection, Type, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<object> QuerySingleOrDefaultAsync(this IDbConnection cnn, Type type, CommandDefinition command)
Returns​

Task<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

QuerySingleOrDefaultAsync<T>(IDbConnection, CommandDefinition)​

Execute a single-row query asynchronously using Task.

View Source​
Declaration
public static Task<T> QuerySingleOrDefaultAsync<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<<T>>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type to return.

ExecuteAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a command asynchronously using Task.

View Source​
Declaration
public static Task<int> ExecuteAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Int32>: The number of rows affected.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

ExecuteAsync(IDbConnection, CommandDefinition)​

Execute a command asynchronously using Task.

View Source​
Declaration
public static Task<int> ExecuteAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<System.Int32>: The number of rows affected.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute on this connection.

|

QueryAsync<TFirst, TSecond, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with 2 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TReturn>(IDbConnection, CommandDefinition, Func<TFirst, TSecond, TReturn>, String)​

Perform a asynchronous multi-mapping query with 2 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TReturn>(this IDbConnection cnn, CommandDefinition command, Func<TFirst, TSecond, TReturn> map, string splitOn = "Id")
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | Func<<TFirst>,<TSecond>,<TReturn>> | map | The function to map row types to the return type.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with 3 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TReturn>(IDbConnection, CommandDefinition, Func<TFirst, TSecond, TThird, TReturn>, String)​

Perform a asynchronous multi-mapping query with 3 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TReturn>(this IDbConnection cnn, CommandDefinition command, Func<TFirst, TSecond, TThird, TReturn> map, string splitOn = "Id")
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | Func<<TFirst>,<TSecond>,<TThird>,<TReturn>> | map | The function to map row types to the return type.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with 4 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TReturn>(IDbConnection, CommandDefinition, Func<TFirst, TSecond, TThird, TFourth, TReturn>, String)​

Perform a asynchronous multi-mapping query with 4 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TReturn>(this IDbConnection cnn, CommandDefinition command, Func<TFirst, TSecond, TThird, TFourth, TReturn> map, string splitOn = "Id")
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TReturn>> | map | The function to map row types to the return type.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with 5 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(IDbConnection, CommandDefinition, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>, String)​

Perform a asynchronous multi-mapping query with 5 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(this IDbConnection cnn, CommandDefinition command, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> map, string splitOn = "Id")
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TReturn>> | map | The function to map row types to the return type.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with 6 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TSixth>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TSixthThe sixth type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(IDbConnection, CommandDefinition, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>, String)​

Perform a asynchronous multi-mapping query with 6 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(this IDbConnection cnn, CommandDefinition command, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn> map, string splitOn = "Id")
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TSixth>,<TReturn>> | map | The function to map row types to the return type.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TSixthThe sixth type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with 7 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TSixth>,<TSeventh>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TSixthThe sixth type in the recordset.
TSeventhThe seventh type in the recordset.
TReturnThe combined type to return.

QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(IDbConnection, CommandDefinition, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>, String)​

Perform an asynchronous multi-mapping query with 7 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(this IDbConnection cnn, CommandDefinition command, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn> map, string splitOn = "Id")
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TSixth>,<TSeventh>,<TReturn>> | map | The function to map row types to the return type.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TSixthThe sixth type in the recordset.
TSeventhThe seventh type in the recordset.
TReturnThe combined type to return.

QueryAsync<TReturn>(IDbConnection, String, Type[], Func<Object[], TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a asynchronous multi-mapping query with an arbitrary number of input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static Task<IEnumerable<TReturn>> QueryAsync<TReturn>(this IDbConnection cnn, string sql, Type[] types, Func<object[], TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IEnumerable<<TReturn>>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Type[] | types | Array of types in the recordset.

| | Func<System.Object[],<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TReturnThe combined type to return.

QueryMultipleAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a command that returns multiple result sets, and access each in turn.

View Source​
Declaration
public static Task<SqlMapper.GridReader> QueryMultipleAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<ServiceStack.OrmLite.Dapper.SqlMapper.GridReader>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

QueryMultipleAsync(IDbConnection, CommandDefinition)​

Execute a command that returns multiple result sets, and access each in turn.

View Source​
Declaration
public static async Task<SqlMapper.GridReader> QueryMultipleAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<ServiceStack.OrmLite.Dapper.SqlMapper.GridReader>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute for this query.

|

ExecuteReaderAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL and return an <see cref="!:IDataReader"></see>.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

View Source​
Declaration
public static Task<IDataReader> ExecuteReaderAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<IDataReader>: An <see cref="!:IDataReader"></see> that can be used to iterate over the results of the SQL query.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.String | sql | The SQL to execute.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.Object | param | The parameters to use for this command.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | IDbTransaction | transaction | The transaction to use for this command.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

|

ExecuteReaderAsync(DbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL and return a <see cref="!:DbDataReader"></see>.

View Source​
Declaration
public static Task<DbDataReader> ExecuteReaderAsync(this DbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<DbDataReader>

Parameters​
TypeNameDescription
DbConnectioncnnThe connection to execute on.

| | System.String | sql | The SQL to execute.

| | System.Object | param | The parameters to use for this command.

| | IDbTransaction | transaction | The transaction to use for this command.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

ExecuteReaderAsync(IDbConnection, CommandDefinition)​

Execute parameterized SQL and return an <see cref="!:IDataReader"></see>.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

View Source​
Declaration
public static Task<IDataReader> ExecuteReaderAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<IDataReader>: An <see cref="!:IDataReader"></see> that can be used to iterate over the results of the SQL query.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

|

ExecuteReaderAsync(DbConnection, CommandDefinition)​

Execute parameterized SQL and return a <see cref="!:DbDataReader"></see>.

View Source​
Declaration
public static Task<DbDataReader> ExecuteReaderAsync(this DbConnection cnn, CommandDefinition command)
Returns​

Task<DbDataReader>

Parameters​
TypeNameDescription
DbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

|

ExecuteReaderAsync(IDbConnection, CommandDefinition, CommandBehavior)​

Execute parameterized SQL and return an <see cref="!:IDataReader"></see>.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

View Source​
Declaration
public static Task<IDataReader> ExecuteReaderAsync(this IDbConnection cnn, CommandDefinition command, CommandBehavior commandBehavior)
Returns​

Task<IDataReader>: An <see cref="!:IDataReader"></see> that can be used to iterate over the results of the SQL query.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | CommandBehavior | commandBehavior | The <see cref="!:CommandBehavior"></see> flags for this reader.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

|

ExecuteReaderAsync(DbConnection, CommandDefinition, CommandBehavior)​

Execute parameterized SQL and return a <see cref="!:DbDataReader"></see>.

View Source​
Declaration
public static Task<DbDataReader> ExecuteReaderAsync(this DbConnection cnn, CommandDefinition command, CommandBehavior commandBehavior)
Returns​

Task<DbDataReader>

Parameters​
TypeNameDescription
DbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

| | CommandBehavior | commandBehavior | The <see cref="!:CommandBehavior"></see> flags for this reader.

|

ExecuteScalarAsync(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static Task<object> ExecuteScalarAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<System.Object>: The first cell returned, as <see cref="!:System.Object"></see>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | System.String | sql | The SQL to execute.

| | System.Object | param | The parameters to use for this command.

| | IDbTransaction | transaction | The transaction to use for this command.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

ExecuteScalarAsync<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static Task<T> ExecuteScalarAsync<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

Task<<T>>: The first cell returned, as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | System.String | sql | The SQL to execute.

| | System.Object | param | The parameters to use for this command.

| | IDbTransaction | transaction | The transaction to use for this command.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TThe type to return.

ExecuteScalarAsync(IDbConnection, CommandDefinition)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static Task<object> ExecuteScalarAsync(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<System.Object>: The first cell selected as <see cref="!:System.Object"></see>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

|

ExecuteScalarAsync<T>(IDbConnection, CommandDefinition)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static Task<T> ExecuteScalarAsync<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

Task<<T>>: The first cell selected as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

|

Type Parameters​
NameDescription
TThe type to return.

PurgeQueryCache()​

Purge the query cache

View Source​
Declaration
public static void PurgeQueryCache()

GetCachedSQLCount()​

Return a count of all the cached queries by Dapper

View Source​
Declaration
public static int GetCachedSQLCount()
Returns​

System.Int32

GetCachedSQL(Int32)​

Return a list of all the queries cached by Dapper

View Source​
Declaration
public static IEnumerable<Tuple<string, string, int>> GetCachedSQL(int ignoreHitCountAbove = null)
Returns​

IEnumerable<Tuple<System.String,System.String,System.Int32>>

Parameters​
TypeName
System.Int32ignoreHitCountAbove

GetHashCollissions()​

Deep diagnostics only: find any hash collisions in the cache

View Source​
Declaration
public static IEnumerable<Tuple<int, int>> GetHashCollissions()
Returns​

IEnumerable<Tuple<System.Int32,System.Int32>>

ResetTypeHandlers()​

Clear the registered type handlers.

View Source​
Declaration
public static void ResetTypeHandlers()

AddTypeMap(Type, DbType)​

Configure the specified type to be mapped to a given db-type.

View Source​
Declaration
public static void AddTypeMap(Type type, DbType dbType)
Parameters​
TypeNameDescription
TypetypeThe type to map from.

| | DbType | dbType | The database type to map to.

|

RemoveTypeMap(Type)​

Removes the specified type from the Type/DbType mapping table.

View Source​
Declaration
public static void RemoveTypeMap(Type type)
Parameters​
TypeNameDescription
TypetypeThe type to remove from the current map.

|

AddTypeHandler(Type, SqlMapper.ITypeHandler)​

Configure the specified type to be processed by a custom handler.

View Source​
Declaration
public static void AddTypeHandler(Type type, SqlMapper.ITypeHandler handler)
Parameters​
TypeNameDescription
TypetypeThe type to handle.

| | ServiceStack.OrmLite.Dapper.SqlMapper.ITypeHandler | handler | The handler to process the <code data-dev-comment-type="paramref" class="paramref">type</code>.

|

AddTypeHandlerImpl(Type, SqlMapper.ITypeHandler, Boolean)​

Configure the specified type to be processed by a custom handler.

View Source​
Declaration
public static void AddTypeHandlerImpl(Type type, SqlMapper.ITypeHandler handler, bool clone)
Parameters​
TypeNameDescription
TypetypeThe type to handle.

| | ServiceStack.OrmLite.Dapper.SqlMapper.ITypeHandler | handler | The handler to process the <code data-dev-comment-type="paramref" class="paramref">type</code>.

| | System.Boolean | clone | Whether to clone the current type handler map.

|

AddTypeHandler<T>(SqlMapper.TypeHandler<T>)​

Configure the specified type to be processed by a custom handler.

View Source​
Declaration
public static void AddTypeHandler<T>(SqlMapper.TypeHandler<T> handler)
Parameters​
TypeNameDescription
ServiceStack.OrmLite.Dapper.SqlMapper.TypeHandler<T>handlerThe handler for the type <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

|

Type Parameters​
NameDescription
TThe type to handle.

GetDbType(Object)​

Get the DbType that maps to a given value.

View Source​
Declaration
public static DbType GetDbType(object value)
Returns​

DbType

Parameters​
TypeNameDescription
System.ObjectvalueThe object to get a corresponding database type for.

|

LookupDbType(Type, String, Boolean, out SqlMapper.ITypeHandler)​

OBSOLETE: For internal usage only. Lookup the DbType and handler for a given Type and member

View Source​
Declaration
public static DbType LookupDbType(Type type, string name, bool demand, out SqlMapper.ITypeHandler handler)
Returns​

DbType

Parameters​
TypeNameDescription
TypetypeThe type to lookup.

| | System.String | name | The name (for error messages).

| | System.Boolean | demand | Whether to demand a value (throw if missing).

| | ServiceStack.OrmLite.Dapper.SqlMapper.ITypeHandler | handler | The handler for <code data-dev-comment-type="paramref" class="paramref">type</code>.

|

AsList<T>(IEnumerable<T>)​

Obtains the data as a list; if it is already a list, the original object is returned without any duplication; otherwise, ToList() is invoked.

View Source​
Declaration
public static List<T> AsList<T>(this IEnumerable<T> source)
Returns​

List<<T>>

Parameters​
TypeNameDescription
IEnumerable<<T>>sourceThe enumerable to return as a list.

|

Type Parameters​
NameDescription
TThe type of element in the list.

Execute(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL.

View Source​
Declaration
public static int Execute(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Int32: The number of rows affected.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Execute(IDbConnection, CommandDefinition)​

Execute parameterized SQL.

View Source​
Declaration
public static int Execute(this IDbConnection cnn, CommandDefinition command)
Returns​

System.Int32: The number of rows affected.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute on this connection.

|

ExecuteScalar(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static object ExecuteScalar(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object: The first cell selected as <see cref="!:System.Object"></see>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | System.String | sql | The SQL to execute.

| | System.Object | param | The parameters to use for this command.

| | IDbTransaction | transaction | The transaction to use for this command.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

ExecuteScalar<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static T ExecuteScalar<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

<T>: The first cell returned, as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | System.String | sql | The SQL to execute.

| | System.Object | param | The parameters to use for this command.

| | IDbTransaction | transaction | The transaction to use for this command.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TThe type to return.

ExecuteScalar(IDbConnection, CommandDefinition)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static object ExecuteScalar(this IDbConnection cnn, CommandDefinition command)
Returns​

System.Object: The first cell selected as <see cref="!:System.Object"></see>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

|

ExecuteScalar<T>(IDbConnection, CommandDefinition)​

Execute parameterized SQL that selects a single value.

View Source​
Declaration
public static T ExecuteScalar<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

<T>: The first cell selected as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

|

Type Parameters​
NameDescription
TThe type to return.

ExecuteReader(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute parameterized SQL and return an <see cref="!:IDataReader"></see>.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

View Source​
Declaration
public static IDataReader ExecuteReader(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

IDataReader: An <see cref="!:IDataReader"></see> that can be used to iterate over the results of the SQL query.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.String | sql | The SQL to execute.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.Object | param | The parameters to use for this command.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | IDbTransaction | transaction | The transaction to use for this command.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

|

ExecuteReader(IDbConnection, CommandDefinition)​

Execute parameterized SQL and return an <see cref="!:IDataReader"></see>.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

View Source​
Declaration
public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinition command)
Returns​

IDataReader: An <see cref="!:IDataReader"></see> that can be used to iterate over the results of the SQL query.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

|

ExecuteReader(IDbConnection, CommandDefinition, CommandBehavior)​

Execute parameterized SQL and return an <see cref="!:IDataReader"></see>.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

View Source​
Declaration
public static IDataReader ExecuteReader(this IDbConnection cnn, CommandDefinition command, CommandBehavior commandBehavior)
Returns​

IDataReader: An <see cref="!:IDataReader"></see> that can be used to iterate over the results of the SQL query.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to execute on.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

| | CommandBehavior | commandBehavior | The <see cref="!:CommandBehavior"></see> flags for this reader.

This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="!:DataTable"></see> or <xref href="DataSet" data-throw-if-not-resolved="false"></xref>.

|

Query(IDbConnection, String, Object, IDbTransaction, Boolean, Nullable<Int32>, Nullable<CommandType>)​

Return a sequence of dynamic objects with properties matching the columns.

Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static IEnumerable<dynamic> Query(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<System.Object>

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.String | sql | The SQL to execute for the query. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Object | param | The parameters to pass, if any. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | IDbTransaction | transaction | The transaction to use, if any. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Boolean | buffered | Whether to buffer the results in memory. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds). Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<CommandType> | commandType | The type of command to execute. Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QueryFirst(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Return a dynamic object with properties matching the columns.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static dynamic QueryFirst(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.String | sql | The SQL to execute for the query. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Object | param | The parameters to pass, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | IDbTransaction | transaction | The transaction to use, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds). Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<CommandType> | commandType | The type of command to execute. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QueryFirstOrDefault(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Return a dynamic object with properties matching the columns.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static dynamic QueryFirstOrDefault(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.String | sql | The SQL to execute for the query. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Object | param | The parameters to pass, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | IDbTransaction | transaction | The transaction to use, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds). Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<CommandType> | commandType | The type of command to execute. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QuerySingle(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Return a dynamic object with properties matching the columns.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static dynamic QuerySingle(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.String | sql | The SQL to execute for the query. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Object | param | The parameters to pass, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | IDbTransaction | transaction | The transaction to use, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds). Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<CommandType> | commandType | The type of command to execute. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

QuerySingleOrDefault(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Return a dynamic object with properties matching the columns.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object>

View Source​
Declaration
public static dynamic QuerySingleOrDefault(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.String | sql | The SQL to execute for the query. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Object | param | The parameters to pass, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | IDbTransaction | transaction | The transaction to use, if any. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds). Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> | | System.Nullable<CommandType> | commandType | The type of command to execute. Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object> |

Query<T>(IDbConnection, String, Object, IDbTransaction, Boolean, Nullable<Int32>, Nullable<CommandType>)​

Executes a query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static IEnumerable<T> Query<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<T>>: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Boolean | buffered | Whether to buffer results in memory.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of results to return.

QueryFirst<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QueryFirst<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

<T>: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

QueryFirstOrDefault<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QueryFirstOrDefault<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

<T>: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

QuerySingle<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QuerySingle<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

<T>: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

QuerySingleOrDefault<T>(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QuerySingleOrDefault<T>(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

<T>: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Type Parameters​
NameDescription
TThe type of result to return.

Query(IDbConnection, Type, String, Object, IDbTransaction, Boolean, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="paramref" class="paramref">type</code>.

View Source​
Declaration
public static IEnumerable<object> Query(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<System.Object>: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Boolean | buffered | Whether to buffer results in memory.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryFirst(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="paramref" class="paramref">type</code>.

View Source​
Declaration
public static object QueryFirst(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QueryFirstOrDefault(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="paramref" class="paramref">type</code>.

View Source​
Declaration
public static object QueryFirstOrDefault(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QuerySingle(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="paramref" class="paramref">type</code>.

View Source​
Declaration
public static object QuerySingle(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

QuerySingleOrDefault(IDbConnection, Type, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Executes a single-row query, returning the data typed as <code data-dev-comment-type="paramref" class="paramref">type</code>.

View Source​
Declaration
public static object QuerySingleOrDefault(this IDbConnection cnn, Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

System.Object: A sequence of data of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | Type | type | The type to return.

| | System.String | sql | The SQL to execute for the query.

| | System.Object | param | The parameters to pass, if any.

| | IDbTransaction | transaction | The transaction to use, if any.

| | System.Nullable<System.Int32> | commandTimeout | The command timeout (in seconds).

| | System.Nullable<CommandType> | commandType | The type of command to execute.

|

Query<T>(IDbConnection, CommandDefinition)​

Executes a query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static IEnumerable<T> Query<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

IEnumerable<<T>>: A sequence of data of <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type of results to return.

QueryFirst<T>(IDbConnection, CommandDefinition)​

Executes a query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QueryFirst<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

<T>: A single instance or null of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type of results to return.

QueryFirstOrDefault<T>(IDbConnection, CommandDefinition)​

Executes a query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QueryFirstOrDefault<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

<T>: A single or null instance of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type of results to return.

QuerySingle<T>(IDbConnection, CommandDefinition)​

Executes a query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QuerySingle<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

<T>: A single instance of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type of results to return.

QuerySingleOrDefault<T>(IDbConnection, CommandDefinition)​

Executes a query, returning the data typed as <code data-dev-comment-type="typeparamref" class="typeparamref">T</code>.

View Source​
Declaration
public static T QuerySingleOrDefault<T>(this IDbConnection cnn, CommandDefinition command)
Returns​

<T>: A single instance of the supplied type; if a basic type (int, string, etc) is queried then the data from the first column in assumed, otherwise an instance is created per row, and a direct column-name===member-name mapping is assumed (case insensitive).

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command used to query on this connection.

|

Type Parameters​
NameDescription
TThe type of results to return.

QueryMultiple(IDbConnection, String, Object, IDbTransaction, Nullable<Int32>, Nullable<CommandType>)​

Execute a command that returns multiple result sets, and access each in turn.

View Source​
Declaration
public static SqlMapper.GridReader QueryMultiple(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
Returns​

ServiceStack.OrmLite.Dapper.SqlMapper.GridReader

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

QueryMultiple(IDbConnection, CommandDefinition)​

Execute a command that returns multiple result sets, and access each in turn.

View Source​
Declaration
public static SqlMapper.GridReader QueryMultiple(this IDbConnection cnn, CommandDefinition command)
Returns​

ServiceStack.OrmLite.Dapper.SqlMapper.GridReader

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | ServiceStack.OrmLite.Dapper.CommandDefinition | command | The command to execute for this query.

|

Query<TFirst, TSecond, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with 2 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TFirst, TSecond, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TReturnThe combined type to return.

Query<TFirst, TSecond, TThird, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with 3 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TReturnThe combined type to return.

Query<TFirst, TSecond, TThird, TFourth, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with 4 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TReturnThe combined type to return.

Query<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with 5 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TReturnThe combined type to return.

Query<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with 6 input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TSixth>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TSixthThe sixth type in the recordset.
TReturnThe combined type to return.

Query<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(IDbConnection, String, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with 7 input types. If you need more types -> use Query with Type[] parameter. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(this IDbConnection cnn, string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Func<<TFirst>,<TSecond>,<TThird>,<TFourth>,<TFifth>,<TSixth>,<TSeventh>,<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TFirstThe first type in the recordset.
TSecondThe second type in the recordset.
TThirdThe third type in the recordset.
TFourthThe fourth type in the recordset.
TFifthThe fifth type in the recordset.
TSixthThe sixth type in the recordset.
TSeventhThe seventh type in the recordset.
TReturnThe combined type to return.

Query<TReturn>(IDbConnection, String, Type[], Func<Object[], TReturn>, Object, IDbTransaction, Boolean, String, Nullable<Int32>, Nullable<CommandType>)​

Perform a multi-mapping query with an arbitrary number of input types. This returns a single type, combined from the raw types via <code data-dev-comment-type="paramref" class="paramref">map</code>.

View Source​
Declaration
public static IEnumerable<TReturn> Query<TReturn>(this IDbConnection cnn, string sql, Type[] types, Func<object[], TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
Returns​

IEnumerable<<TReturn>>: An enumerable of <code data-dev-comment-type="typeparamref" class="typeparamref">TReturn</code>.

Parameters​
TypeNameDescription
IDbConnectioncnnThe connection to query on.

| | System.String | sql | The SQL to execute for this query.

| | Type[] | types | Array of types in the recordset.

| | Func<System.Object[],<TReturn>> | map | The function to map row types to the return type.

| | System.Object | param | The parameters to use for this query.

| | IDbTransaction | transaction | The transaction to use for this query.

| | System.Boolean | buffered | Whether to buffer the results in memory.

| | System.String | splitOn | The field we should split and read the second object from (default: "Id").

| | System.Nullable<System.Int32> | commandTimeout | Number of seconds before command execution timeout.

| | System.Nullable<CommandType> | commandType | Is it a stored proc or a batch?

|

Type Parameters​
NameDescription
TReturnThe combined type to return.

ReadChar(Object)​

Internal use only.

View Source​
Declaration
public static char ReadChar(object value)
Returns​

System.Char

Parameters​
TypeNameDescription
System.ObjectvalueThe object to convert to a character.

|

ReadNullableChar(Object)​

Internal use only.

View Source​
Declaration
public static char? ReadNullableChar(object value)
Returns​

System.Nullable<System.Char>

Parameters​
TypeNameDescription
System.ObjectvalueThe object to convert to a character.

|

FindOrAddParameter(IDataParameterCollection, IDbCommand, String)​

Internal use only.

View Source​
Declaration
public static IDbDataParameter FindOrAddParameter(IDataParameterCollection parameters, IDbCommand command, string name)
Returns​

IDbDataParameter

Parameters​
TypeNameDescription
IDataParameterCollectionparametersThe parameter collection to search in.

| | IDbCommand | command | The command for this fetch.

| | System.String | name | The name of the parameter to get.

|

PackListParameters(IDbCommand, String, Object)​

Internal use only.

View Source​
Declaration
public static void PackListParameters(IDbCommand command, string namePrefix, object value)
Parameters​
TypeNameDescription
IDbCommandcommandThe command to pack parameters for.

| | System.String | namePrefix | The name prefix for these parameters.

| | System.Object | value | The parameter value can be an <see cref="!:IEnumerable<T>"></see>

|

SanitizeParameterValue(Object)​

OBSOLETE: For internal usage only. Sanitizes the paramter value with proper type casting.

View Source​
Declaration
public static object SanitizeParameterValue(object value)
Returns​

System.Object

Parameters​
TypeNameDescription
System.ObjectvalueThe value to sanitize.

|

ReplaceLiterals(SqlMapper.IParameterLookup, IDbCommand)​

Replace all literal tokens with their text form.

View Source​
Declaration
public static void ReplaceLiterals(this SqlMapper.IParameterLookup parameters, IDbCommand command)
Parameters​
TypeNameDescription
ServiceStack.OrmLite.Dapper.SqlMapper.IParameterLookupparametersThe parameter lookup to do replacements with.

| | IDbCommand | command | The command to repalce parameters in.

|

Format(Object)​

Convert numeric values to their string form for SQL literal purposes.

View Source​
Declaration
public static string Format(object value)
Returns​

System.String

Parameters​
TypeNameDescription
System.ObjectvalueThe value to get a string for.

|

CreateParamInfoGenerator(SqlMapper.Identity, Boolean, Boolean)​

Internal use only.

View Source​
Declaration
public static Action<IDbCommand, object> CreateParamInfoGenerator(SqlMapper.Identity identity, bool checkForDuplicates, bool removeUnused)
Returns​

Action<IDbCommand,System.Object>

Parameters​
TypeNameDescription
ServiceStack.OrmLite.Dapper.SqlMapper.IdentityidentityThe identity of the generator.

| | System.Boolean | checkForDuplicates | Whether to check for duplicates.

| | System.Boolean | removeUnused | Whether to remove unused parameters.

|

GetTypeMap(Type)​

Gets type-map for the given <see cref="!:Type"></see>.

View Source​
Declaration
public static SqlMapper.ITypeMap GetTypeMap(Type type)
Returns​

ServiceStack.OrmLite.Dapper.SqlMapper.ITypeMap: Type map implementation, DefaultTypeMap instance if no override present

Parameters​
TypeNameDescription
TypetypeThe type to get a map for.

|

SetTypeMap(Type, SqlMapper.ITypeMap)​

Set custom mapping for type deserializers

View Source​
Declaration
public static void SetTypeMap(Type type, SqlMapper.ITypeMap map)
Parameters​
TypeNameDescription
TypetypeEntity type to override

| | ServiceStack.OrmLite.Dapper.SqlMapper.ITypeMap | map | Mapping rules impementation, null to remove custom map

|

GetTypeDeserializer(Type, IDataReader, Int32, Int32, Boolean)​

Internal use only

View Source​
Declaration
public static Func<IDataReader, object> GetTypeDeserializer(Type type, IDataReader reader, int startBound = 0, int length = null, bool returnNullIfFirstMissing = false)
Returns​

Func<IDataReader,System.Object>

Parameters​
TypeName
Typetype
IDataReaderreader
System.Int32startBound
System.Int32length
System.BooleanreturnNullIfFirstMissing

ThrowDataException(Exception, Int32, IDataReader, Object)​

Throws a data exception, only used internally

View Source​
Declaration
public static void ThrowDataException(Exception ex, int index, IDataReader reader, object value)
Parameters​
TypeNameDescription
ExceptionexThe exception to throw.

| | System.Int32 | index | The index the exception occured at.

| | IDataReader | reader | The reader the exception occured in.

| | System.Object | value | The value that caused the exception.

|

AsTableValuedParameter(DataTable, String)​

Used to pass a DataTable as a ServiceStack.OrmLite.Dapper.TableValuedParameter.

View Source​
Declaration
public static SqlMapper.ICustomQueryParameter AsTableValuedParameter(this DataTable table, string typeName = null)
Returns​

ServiceStack.OrmLite.Dapper.SqlMapper.ICustomQueryParameter

Parameters​
TypeNameDescription
DataTabletableThe <see cref="!:DataTable"></see> to create this parameter for.

| | System.String | typeName | The name of the type this parameter is for.

|

SetTypeName(DataTable, String)​

Associate a DataTable with a type name.

View Source​
Declaration
public static void SetTypeName(this DataTable table, string typeName)
Parameters​
TypeNameDescription
DataTabletableThe <see cref="!:DataTable"></see> that does with the <code data-dev-comment-type="paramref" class="paramref">typeName</code>.

| | System.String | typeName | The name of the type this table is for.

|

GetTypeName(DataTable)​

Fetch the type name associated with a <see cref="!:DataTable"></see>.

View Source​
Declaration
public static string GetTypeName(this DataTable table)
Returns​

System.String

Parameters​
TypeNameDescription
DataTabletableThe <see cref="!:DataTable"></see> that has a type name associated with it.

|

AsTableValuedParameter<T>(IEnumerable<T>, String)​

Used to pass a IEnumerable<SqlDataRecord> as a TableValuedParameter.

View Source​
Declaration
public static SqlMapper.ICustomQueryParameter AsTableValuedParameter<T>(this IEnumerable<T> list, string typeName = null)
where T : IDataRecord
Returns​

ServiceStack.OrmLite.Dapper.SqlMapper.ICustomQueryParameter

Parameters​
TypeNameDescription
IEnumerable<<T>>listThe list of records to convert to TVPs.

| | System.String | typeName | The sql parameter type name.

|

Type Parameters​
  • T

Parse<T>(IDataReader)​

Parses a data reader to a sequence of data of the supplied type. Used for deserializing a reader without a connection, etc.

View Source​
Declaration
public static IEnumerable<T> Parse<T>(this IDataReader reader)
Returns​

IEnumerable<<T>>

Parameters​
TypeNameDescription
IDataReaderreaderThe data reader to parse results from.

|

Type Parameters​
NameDescription
TThe type to parse from the reader.

Parse(IDataReader, Type)​

Parses a data reader to a sequence of data of the supplied type (as object). Used for deserializing a reader without a connection, etc.

View Source​
Declaration
public static IEnumerable<object> Parse(this IDataReader reader, Type type)
Returns​

IEnumerable<System.Object>

Parameters​
TypeNameDescription
IDataReaderreaderThe data reader to parse results from.

| | Type | type | The type to parse from the <code data-dev-comment-type="paramref" class="paramref">reader</code>.

|

Parse(IDataReader)​

Parses a data reader to a sequence of dynamic. Used for deserializing a reader without a connection, etc.

View Source​
Declaration
public static IEnumerable<dynamic> Parse(this IDataReader reader)
Returns​

IEnumerable<System.Object>

Parameters​
TypeNameDescription
IDataReaderreaderThe data reader to parse results from.

|

GetRowParser(IDataReader, Type, Int32, Int32, Boolean)​

Gets the row parser for a specific row on a data reader. This allows for type switching every row based on, for example, a TypeId column. You could return a collection of the base type but have each more specific.

View Source​
Declaration
public static Func<IDataReader, object> GetRowParser(this IDataReader reader, Type type, int startIndex = 0, int length = null, bool returnNullIfFirstMissing = false)
Returns​

Func<IDataReader,System.Object>: A parser for this specific object from this row.

Parameters​
TypeNameDescription
IDataReaderreaderThe data reader to get the parser for the current row from

| | Type | type | The type to get the parser for

| | System.Int32 | startIndex | The start column index of the object (default 0)

| | System.Int32 | length | The length of columns to read (default -1 = all fields following startIndex)

| | System.Boolean | returnNullIfFirstMissing | Return null if we can't find the first column? (default false)

|

GetRowParser<T>(IDataReader, Type, Int32, Int32, Boolean)​

Gets the row parser for a specific row on a data reader. This allows for type switching every row based on, for example, a TypeId column. You could return a collection of the base type but have each more specific.

View Source​
Declaration
public static Func<IDataReader, T> GetRowParser<T>(this IDataReader reader, Type concreteType = null, int startIndex = 0, int length = null, bool returnNullIfFirstMissing = false)
Returns​

Func<IDataReader,<T>>: A parser for this specific object from this row.

Parameters​
TypeNameDescription
IDataReaderreaderThe data reader to get the parser for the current row from.

| | Type | concreteType | The type to get the parser for.

| | System.Int32 | startIndex | The start column index of the object (default: 0).

| | System.Int32 | length | The length of columns to read (default: -1 = all fields following startIndex).

| | System.Boolean | returnNullIfFirstMissing | Return null if we can't find the first column? (default: false).

|

Type Parameters​
NameDescription
TThe type of results to return.

Events​

QueryCachePurged​

Called if the query cache is purged via PurgeQueryCache

View Source​
Declaration
public static event EventHandler QueryCachePurged
Event Type​

EventHandler