/// <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="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null)
        {
            var sql = scripts.GetScriptSql(key, param);

            return(connection.QuerySingleOrDefault <T>(sql, param, transaction, commandTimeout, commandType));
        }
        /// <summary>
        /// Execute a command that returns multiple result sets, and access each in turn.
        /// </summary>
        /// <param name="connection">The database connection.</param>
        /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null)
        {
            var sql = scripts.GetScriptSql(key, param);

            return(connection.QueryMultiple(sql, param, transaction, commandTimeout, commandType));
        }
 /// <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="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static T QuerySingleOrDefaultScript <T>(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return(connection.QuerySingleOrDefault <T>(command.ToSqlDefinition(scripts)));
 }
        /// <summary>
        /// Executes a query, returning the data typed as per <typeparamref name="T"/>.
        /// </summary>
        /// <param name="connection">The database connection.</param>
        /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, string key, object param = null, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null)
        {
            var sql = scripts.GetScriptSql(key, param);

            return(connection.Query <T>(sql, param, transaction, buffered, commandTimeout, commandType));
        }
 /// <summary>
 /// Execute a command that returns multiple result sets, and access each in turn.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static SqlMapper.GridReader QueryMultipleScript(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return(connection.QueryMultiple(command.ToSqlDefinition(scripts)));
 }
        /// <summary>
        /// Execute a parameterized SQL script that returns a single value.
        /// </summary>
        /// <param name="connection">The database connection.</param>
        /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, string key, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null)
        {
            var sql = scripts.GetScriptSql(key, param);

            return(connection.ExecuteScalar(sql, param, transaction, commandTimeout, commandType));
        }
예제 #7
0
 /// <summary>
 /// Execute a single-row SQL script query asynchronously using Task.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, string key, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
 {
     var sql = scripts.GetScriptSql(key, param);
     return await connection.QueryFirstAsync<T>(sql, param, transaction, commandTimeout, commandType);
 }
예제 #8
0
 /// <summary>
 /// Execute a parameterized SQL script asynchronously and return an <seealso cref="IDataReader"/>.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, string key, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
 {
     var sql = scripts.GetScriptSql(key, param);
     return await connection.ExecuteReaderAsync(sql, param, transaction, commandTimeout, commandType);
 }
예제 #9
0
 /// <summary>
 /// Execute a parameterized SQL script asynchronously that selects a single value.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static async Task<object> ExecuteScalarScriptAsync(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return await connection.ExecuteScalarAsync(command.ToSqlDefinition(scripts));
 }
예제 #10
0
 /// <summary>
 /// Execute a single-row SQL script query asynchronously using Task.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static async Task<T> QuerySingleOrDefaultScriptAsync<T>(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return await connection.QuerySingleOrDefaultAsync<T>(command.ToSqlDefinition(scripts));
 }
예제 #11
0
 /// <summary>
 /// Execute a parameterized SQL script asynchronously and return an <seealso cref="IDataReader"/>.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static async Task<IDataReader> ExecuteReaderScriptAsync(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return await connection.ExecuteReaderAsync(command.ToSqlDefinition(scripts));
 }
예제 #12
0
 /// <summary>
 /// Execute a single-row SQL script query asynchronously using Task.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</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 DbConnection connection, ISqlScriptCollection scripts, Type type, string key, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
 {
     var sql = scripts.GetScriptSql(key, param);
     return await connection.QuerySingleOrDefaultAsync(type, sql, param, transaction, commandTimeout, commandType);
 }
예제 #13
0
 /// <summary>
 /// Execute a single-row SQL script query asynchronously using Task.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static async Task<dynamic> QuerySingleScriptAsync(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return await connection.QuerySingleAsync(command.ToSqlDefinition(scripts));
 }
예제 #14
0
 /// <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="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static async Task<SqlMapper.GridReader> QueryMultipleScriptAsync(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return await connection.QueryMultipleAsync(command.ToSqlDefinition(scripts));
 }
 /// <summary>
 /// Execute a parameterized SQL script and return an <seealso cref="IDataReader"/>.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static IDataReader ExecuteReaderScript(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return(connection.ExecuteReader(command.ToSqlDefinition(scripts)));
 }
예제 #16
0
        /// <summary>
        /// Creates a new instance of <see cref="CommandDefinition"/>
        /// using the current settings.
        /// </summary>
        /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
        public CommandDefinition ToSqlDefinition(ISqlScriptCollection scripts)
        {
            var sql = scripts.GetScriptSql(Key, Parameters);

            return(new CommandDefinition(sql, Parameters, Transaction, CommandTimeout, CommandType, Flags, CancellationToken));
        }
 /// <summary>
 /// Execute a parameterized SQL script that returns a single value.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static object ExecuteScalarScript(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return(connection.ExecuteScalar(command.ToSqlDefinition(scripts)));
 }
 /// <summary>
 /// Executes a query, returning the data typed as per <typeparamref name="T"/>.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static IEnumerable <T> QueryScript <T>(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return(connection.Query <T>(command.ToSqlDefinition(scripts)));
 }
예제 #19
0
 /// <summary>
 /// Creates a new instance of the <see cref="SqlScriptConnectionFactory"/>.
 /// </summary>
 /// <param name="scripts">The collection of SQL scripts to use for connection bindings.</param>
 public SqlScriptConnectionFactory(ISqlScriptCollection scripts)
 {
     scriptCollection = scripts;
 }
예제 #20
0
 /// <summary>
 /// Execute a SQL script query asynchronously using Task.
 /// </summary>
 /// <param name="connection">The database connection.</param>
 /// <param name="scripts">The collection of scripts used to populate the commands SQL text.</param>
 /// <param name="command">The command to execute on this connection.</param>
 public static async Task<IEnumerable<T>> QueryScriptAsync<T>(this DbConnection connection, ISqlScriptCollection scripts, ScriptCommandDefinition command)
 {
     return await connection.QueryAsync<T>(command.ToSqlDefinition(scripts));
 }