/// <summary> /// Execute a command that returns multiple result sets, and access each in turn. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static SqlMapper.GridReader QueryMultipleScript(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(connection.QueryMultiple(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a command that returns multiple result sets, and access each in turn. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 SqlMapper.GridReader QueryMultipleScript(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(connection.QueryMultiple(sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Execute a parameterized SQL script. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static int ExecuteScript(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(connection.Execute(command.ToSqlDefinition(connection))); }
/// <summary> /// Return a dynamic object with properties matching the columns. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 dynamic QueryFirstScript(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(connection.QueryFirst(sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Execute a parameterized SQL script that returns a single value. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static T ExecuteScalarScript <T>(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(connection.ExecuteScalar <T>(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a single-row SQL script query asynchronously using Task. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 async Task <T> QueryFirstScriptAsync <T>(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(await connection.QueryFirstAsync <T>(sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Execute a parameterized SQL script asynchronously and return an <seealso cref="IDataReader"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 async Task <IDataReader> ExecuteReaderScriptAsync(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(await connection.ExecuteReaderAsync(sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Execute a parameterized SQL script and return an <seealso cref="IDataReader"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static IDataReader ExecuteReaderScript(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(connection.ExecuteReader(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a single-row SQL script query asynchronously using Task. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static async Task <T> QuerySingleOrDefaultScriptAsync <T>(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(await connection.QuerySingleOrDefaultAsync <T>(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a parameterized SQL script asynchronously and return an <seealso cref="IDataReader"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static async Task <IDataReader> ExecuteReaderScriptAsync(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(await connection.ExecuteReaderAsync(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a single-row SQL script query asynchronously using Task. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="type">The type to return.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 async Task <dynamic> QuerySingleOrDefaultScriptAsync(this ISqlScriptConnection connection, Type type, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(await connection.QuerySingleOrDefaultAsync(type, sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Execute a single-row SQL script query asynchronously using Task. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static async Task <dynamic> QuerySingleScriptAsync(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(await connection.QuerySingleAsync(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a SQL script that returns multiple result sets, and access each in turn. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static async Task <SqlMapper.GridReader> QueryMultipleScriptAsync(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(await connection.QueryMultipleAsync(command.ToSqlDefinition(connection))); }
/// <summary> /// Executes a single-row query, returning the data typed as per <typeparamref name="T"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static T QuerySingleOrDefaultScript <T>(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(connection.QuerySingleOrDefault <T>(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a parameterized SQL script asynchronously that selects a single value. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static async Task <T> ExecuteScalarScriptAsync <T>(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(await connection.ExecuteScalarAsync <T>(command.ToSqlDefinition(connection))); }
/// <summary> /// Executes a single-row query, returning the data typed as per <typeparamref name="T"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 T QuerySingleOrDefaultScript <T>(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(connection.QuerySingleOrDefault <T>(sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Executes a query, returning the data typed as per <typeparamref name="T"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static IEnumerable <T> QueryScript <T>(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(connection.Query <T>(command.ToSqlDefinition(connection))); }
/// <summary> /// Execute a parameterized SQL script that returns a single value. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction 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 object ExecuteScalarScript(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(connection.ExecuteScalar(sql, param, transaction, commandTimeout, commandType)); }
/// <summary> /// Executes a query, returning the data typed as per <typeparamref name="T"/>. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="key">The named identifier of the SQL script.</param> /// <param name="param">Optional collection of parameters used by SQL script and transformer.</param> /// <param name="transaction">The transaction to use for this query.</param> /// <param name="buffered">Whether to buffer the results in memory.</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 IEnumerable <T> QueryScript <T>(this ISqlScriptConnection connection, string key, object param = null, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null) { var sql = connection.GetScriptSql(key, param); return(connection.Query <T>(sql, param, transaction, buffered, commandTimeout, commandType)); }
/// <summary> /// Creates a new instance of <see cref="CommandDefinition"/> /// using the current settings. /// </summary> /// <param name="connection">The script connection used to execute the command.</param> public CommandDefinition ToSqlDefinition(ISqlScriptConnection connection) { var sql = connection.GetScriptSql(Key, Parameters); return(new CommandDefinition(sql, Parameters, Transaction, CommandTimeout, CommandType, Flags, CancellationToken)); }
/// <summary> /// Execute a SQL script query asynchronously using Task. /// </summary> /// <param name="connection">The database connection.</param> /// <param name="command">The command to execute on this connection.</param> public static async Task <IEnumerable <T> > QueryScriptAsync <T>(this ISqlScriptConnection connection, ScriptCommandDefinition command) { return(await connection.QueryAsync <T>(command.ToSqlDefinition(connection))); }