I have the following scenario. I have a large number of similar databases falling into 2 sets (call them ADatabases and BDatabases). I very commonly want to run a single job against every ADatabase, or a single job against every BDatabase. I am creating a job per database to run against since they can all safely run in parallel and I want to guarantee that it is run everywhere at least once.
So, I wrote an extension method for BackgroundJobClient.EnqueueAllDatabaseA(Expression<Action> methodCall) that simply loops through every databaseA and enqueues the job to run against the database. The problem with this though, is that each job needs to know which database it’s running against, in addition to any parameters that may be passed into the normal Enqueue method.
public class DatabaseAJob {
public string DatabaseName { get; set; }
public void Execute(int someParameter)
}
Is there an easy way to add additional parameters to the method to be called so that I can have a single call within my application that will trigger a job with a given parameter on every database?