/// <summary>
 /// Execute a command that returns multiple result sets, and access each in turn.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="command">The command to execute for this query.</param>
 public static Task <SqlMapper.GridReader> QueryMultipleAsync(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryMultipleAsync(command));
 }
示例#2
0
 /// <summary>
 /// Perform a multi-mapping query with 3 input types.
 /// This returns a single type, combined from the raw types via <paramref name="map"/>.
 /// </summary>
 /// <typeparam name="TFirst">The first type in the recordset.</typeparam>
 /// <typeparam name="TSecond">The second type in the recordset.</typeparam>
 /// <typeparam name="TThird">The third type in the recordset.</typeparam>
 /// <typeparam name="TReturn">The combined type to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="sql">The SQL to execute for this query.</param>
 /// <param name="map">The function to map row types to the return type.</param>
 /// <param name="param">The parameters to use for this query.</param>
 /// <param name="buffered">Whether to buffer the results in memory.</param>
 /// <param name="splitOn">The field we should split and read the second object from (default: "Id").</param>
 /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
 /// <param name="commandType">Is it a stored proc or a batch?</param>
 /// <returns>An enumerable of <typeparamref name="TReturn"/>.</returns>
 public static Task <IEnumerable <TReturn> > QueryAsync <TFirst, TSecond, TThird, TReturn>(this IDbTransaction transaction, string sql, Func <TFirst, TSecond, TThird, TReturn> map, object param = null, bool buffered = true, string splitOn = "Id", int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryAsync <TFirst, TSecond, TThird, TReturn>(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType));
 }
 /// <summary>
 /// Execute a command that returns multiple result sets, and access each in turn.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="sql">The SQL to execute for this query.</param>
 /// <param name="param">The parameters to use for this query.</param>
 /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
 /// <param name="commandType">Is it a stored proc or a batch?</param>
 public static Task <SqlMapper.GridReader> QueryMultipleAsync(this IDbTransaction transaction, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryMultipleAsync(sql, param, transaction, commandTimeout, commandType));
 }
示例#4
0
 /// <summary>
 /// Execute parameterized SQL that selects a single value.
 /// </summary>
 /// <param name="transaction">The transaction to execute on.</param>
 /// <param name="sql">The SQL to execute.</param>
 /// <param name="param">The parameters to use for this command.</param>
 /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
 /// <param name="commandType">Is it a stored proc or a batch?</param>
 /// <returns>The first cell selected as <see cref="object"/>.</returns>
 public static object ExecuteScalar(this IDbTransaction transaction, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteScalar(sql, param, transaction, commandTimeout, commandType));
 }
 /// <summary>
 /// Execute parameterized SQL and return a <see cref="DbDataReader"/>.
 /// </summary>
 /// <param name="transaction">The transaction to execute on.</param>
 /// <param name="sql">The SQL to execute.</param>
 /// <param name="param">The parameters to use for this command.</param>
 /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
 /// <param name="commandType">Is it a stored proc or a batch?</param>
 public static Task <DbDataReader> ExecuteReaderAsync(this DbTransaction transaction, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteReaderAsync(sql, param, transaction, commandTimeout, commandType));
 }
示例#6
0
 /// <summary>
 /// Execute a query asynchronously using Task.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="command">The command used to query on this connection.</param>
 /// <remarks>Note: each row can be accessed via "dynamic", or by casting to an IDictionary&lt;string,object&gt;</remarks>
 public static Task <IEnumerable <dynamic> > QueryAsync(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryAsync(command));
 }
 /// <summary>
 /// Executes a single-row query, returning the data typed as <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">The type of result to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="sql">The SQL to execute for the query.</param>
 /// <param name="param">The parameters to pass, if any.</param>
 /// <param name="commandTimeout">The command timeout (in seconds).</param>
 /// <param name="commandType">The type of command to execute.</param>
 /// <returns>
 /// 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).
 /// </returns>
 public static T QueryFirst <T>(this IDbTransaction transaction, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryFirst <T>(sql, param, transaction, commandTimeout, commandType));
 }
示例#8
0
 /// <summary>
 /// Executes a query, returning the data typed as <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">The type of results to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="command">The command used to query on this connection.</param>
 /// <returns>
 /// A sequence of data of <typeparamref name="T"/>; 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).
 /// </returns>
 public static IEnumerable <T> Query <T>(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).Query <T>(command));
 }
示例#9
0
 /// <summary>
 /// Return a dynamic object with properties matching the columns.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="sql">The SQL to execute for the query.</param>
 /// <param name="param">The parameters to pass, if any.</param>
 /// <param name="commandTimeout">The command timeout (in seconds).</param>
 /// <param name="commandType">The type of command to execute.</param>
 /// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary&lt;string,object&gt;</remarks>
 public static dynamic QuerySingleOrDefault(this IDbTransaction transaction, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).QuerySingleOrDefault(sql, param, transaction, commandTimeout, commandType));
 }
 /// <summary>
 /// Executes a query, returning the data typed as <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">The type of results to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="command">The command used to query on this connection.</param>
 /// <returns>
 /// 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).
 /// </returns>
 public static Task <T> QuerySingleAsync <T>(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QuerySingleAsync <T>(command));
 }
示例#11
0
 /// <summary>
 /// Perform a multi-mapping query with an arbitrary number of input types.
 /// This returns a single type, combined from the raw types via <paramref name="map"/>.
 /// </summary>
 /// <typeparam name="TReturn">The combined type to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="sql">The SQL to execute for this query.</param>
 /// <param name="types">Array of types in the recordset.</param>
 /// <param name="map">The function to map row types to the return type.</param>
 /// <param name="param">The parameters to use for this query.</param>
 /// <param name="buffered">Whether to buffer the results in memory.</param>
 /// <param name="splitOn">The field we should split and read the second object from (default: "Id").</param>
 /// <param name="commandTimeout">Number of seconds before command execution timeout.</param>
 /// <param name="commandType">Is it a stored proc or a batch?</param>
 /// <returns>An enumerable of <typeparamref name="TReturn"/>.</returns>
 public static IEnumerable <TReturn> Query <TReturn>(this IDbTransaction transaction, string sql, Type[] types, Func <object[], TReturn> map, object param = null, bool buffered = true, string splitOn = "Id", int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).Query <TReturn>(sql, types, map, param, transaction, buffered, splitOn, commandTimeout, commandType));
 }
 /// <summary>
 /// Execute parameterized SQL that selects a single value.
 /// </summary>
 /// <typeparam name="T">The type to return.</typeparam>
 /// <param name="transaction">The transaction to execute on.</param>
 /// <param name="command">The command to execute.</param>
 /// <returns>The first cell selected as <typeparamref name="T"/>.</returns>
 public static Task <T> ExecuteScalarAsync <T>(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteScalarAsync <T>(command));
 }
 /// <summary>
 /// Execute parameterized SQL and return a <see cref="DbDataReader"/>.
 /// </summary>
 /// <param name="transaction">The transaction to execute on.</param>
 /// <param name="command">The command to execute.</param>
 /// <param name="commandBehavior">The <see cref="CommandBehavior"/> flags for this reader.</param>
 public static Task <DbDataReader> ExecuteReaderAsync(this DbTransaction transaction, CommandDefinition command, CommandBehavior commandBehavior)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteReaderAsync(command, commandBehavior));
 }
 /// <summary>
 /// Execute parameterized SQL and return an <see cref="IDataReader"/>.
 /// </summary>
 /// <param name="transaction">The transaction to execute on.</param>
 /// <param name="command">The command to execute.</param>
 /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
 /// <remarks>
 /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
 /// or <see cref="T:DataSet"/>.
 /// </remarks>
 public static Task <IDataReader> ExecuteReaderAsync(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteReaderAsync(command));
 }
示例#15
0
 /// <summary>
 /// Executes a single-row query, returning the data typed as <paramref name="type"/>.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="type">The type to return.</param>
 /// <param name="sql">The SQL to execute for the query.</param>
 /// <param name="param">The parameters to pass, if any.</param>
 /// <param name="buffered">Whether to buffer results in memory.</param>
 /// <param name="commandTimeout">The command timeout (in seconds).</param>
 /// <param name="commandType">The type of command to execute.</param>
 /// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
 /// <returns>
 /// 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).
 /// </returns>
 public static IEnumerable <dynamic> Query(this IDbTransaction transaction, Type type, string sql, object param = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).Query(type, sql, param, transaction, buffered, commandTimeout, commandType));
 }
 /// <summary>
 /// Execute a single-row query asynchronously using Task.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="command">The command used to query on this connection.</param>
 /// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary&lt;string,object&gt;</remarks>
 public static Task <dynamic> QuerySingleOrDefaultAsync(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QuerySingleOrDefaultAsync(command));
 }
示例#17
0
 /// <summary>
 /// Execute a query asynchronously using Task.
 /// </summary>
 /// <param name="cnn">The connection to query on.</param>
 /// <param name="type">The type to return.</param>
 /// <param name="sql">The SQL to execute for the query.</param>
 /// <param name="param">The parameters to pass, if any.</param>
 /// <param name="commandTimeout">The command timeout (in seconds).</param>
 /// <param name="commandType">The type of command to execute.</param>
 /// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
 public static Task <IEnumerable <dynamic> > QueryAsync(this IDbTransaction transaction, Type type, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryAsync(type, sql, param, transaction, commandTimeout, commandType));
 }
 /// <summary>
 /// Execute a single-row query asynchronously using Task.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="type">The type to return.</param>
 /// <param name="command">The command used to query on this connection.</param>
 public static Task <object> QuerySingleOrDefaultAsync(this IDbTransaction transaction, Type type, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QuerySingleOrDefaultAsync(type, command));
 }
示例#19
0
 /// <summary>
 /// Execute a query asynchronously using Task.
 /// </summary>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="type">The type to return.</param>
 /// <param name="command">The command used to query on this connection.</param>
 public static Task <IEnumerable <object> > QueryAsync(this IDbTransaction transaction, Type type, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryAsync(type, command));
 }
 /// <summary>
 /// Execute a single-row query asynchronously using Task.
 /// </summary>
 /// <param name="transaction">The connection to query on.</param>
 /// <param name="type">The type to return.</param>
 /// <param name="sql">The SQL to execute for the query.</param>
 /// <param name="param">The parameters to pass, if any.</param>
 /// <param name="commandTimeout">The command timeout (in seconds).</param>
 /// <param name="commandType">The type of command to execute.</param>
 /// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
 public static Task <object> QuerySingleOrDefaultAsync(this IDbTransaction transaction, Type type, string sql, object param = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(InternalGetConnection.GetConnection(transaction).QuerySingleOrDefaultAsync(type, sql, param, transaction, commandTimeout, commandType));
 }
 /// <summary>
 /// Executes a query, returning the data typed as <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">The type of results to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="command">The command used to query on this connection.</param>
 /// <returns>
 /// 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).
 /// </returns>
 public static T QueryFirst <T>(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).QueryFirst <T>(command));
 }
示例#22
0
 /// <summary>
 /// Perform a asynchronous multi-mapping query with 2 input types.
 /// This returns a single type, combined from the raw types via <paramref name="map"/>.
 /// </summary>
 /// <typeparam name="TFirst">The first type in the recordset.</typeparam>
 /// <typeparam name="TSecond">The second type in the recordset.</typeparam>
 /// <typeparam name="TReturn">The combined type to return.</typeparam>
 /// <param name="transaction">The transaction to query on.</param>
 /// <param name="splitOn">The field we should split and read the second object from (default: "Id").</param>
 /// <param name="command">The command to execute.</param>
 /// <param name="map">The function to map row types to the return type.</param>
 /// <returns>An enumerable of <typeparamref name="TReturn"/>.</returns>
 public static Task <IEnumerable <TReturn> > QueryAsync <TFirst, TSecond, TReturn>(this IDbTransaction transaction, CommandDefinition command, Func <TFirst, TSecond, TReturn> map, string splitOn = "Id")
 {
     return(InternalGetConnection.GetConnection(transaction).QueryAsync <TFirst, TSecond, TReturn>(command, map, splitOn));
 }
示例#23
0
 /// <summary>
 /// Execute parameterized SQL that selects a single value.
 /// </summary>
 /// <param name="transaction">The transaction to execute on.</param>
 /// <param name="command">The command to execute.</param>
 /// <returns>The first cell selected as <see cref="object"/>.</returns>
 public static object ExecuteScalar(this IDbTransaction transaction, CommandDefinition command)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteScalar(command));
 }
 /// <summary>
 /// Execute parameterized SQL and return an <see cref="IDataReader"/>.
 /// </summary>
 /// <param name="cnn">The connection to execute on.</param>
 /// <param name="command">The command to execute.</param>
 /// <param name="commandBehavior">The <see cref="CommandBehavior"/> flags for this reader.</param>
 /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
 /// <remarks>
 /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
 /// or <see cref="T:DataSet"/>.
 /// </remarks>
 public static IDataReader ExecuteReader(this IDbTransaction transaction, CommandDefinition command, CommandBehavior commandBehavior)
 {
     return(InternalGetConnection.GetConnection(transaction).ExecuteReader(command, commandBehavior));
 }