public void SqlJobTaskShouldExecuteSqlStatements() { var conn = new SqlConnection {ConnectionString = Settings.Default.ConnectionString}; conn.Open(); var sqlJobTask = new SqlJobTask("test", "select 'executing'") {Connection = conn}; sqlJobTask.Execute(); conn.Close(); }
private void AddSqlJobTasksFromResourcesIfAny() { var allResourceNames = GetType().Assembly.GetManifestResourceNames(); Array.Sort(allResourceNames); IEnumerable<string> sqlResourceNames = GetSqlFileNames(allResourceNames); foreach (var resourceName in sqlResourceNames) { var sqlJobTask = new SqlJobTask(resourceName, GetSqlScript(resourceName)) {UndoSql = GetUndoSqlScriptIfFound(allResourceNames, resourceName)}; JobTasks.Add(sqlJobTask); } }
private void ApplyParameters(SqlJobTask sqlCmd) { var sqlParameters = new Dictionary<string, object>(); foreach (var parameter in Parameters) { if (CurlyParameterPattern.IsMatch(parameter.Key)) { sqlCmd.Sql = sqlCmd.Sql.Replace(parameter.Key, parameter.Value.ToString()); sqlCmd.UndoSql = sqlCmd.UndoSql.Replace(parameter.Key, parameter.Value.ToString()); } else sqlParameters.Add(parameter.Key, parameter.Value); } sqlCmd.Parameters = sqlParameters; }