Pass dynamic construction parameters?

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?

Alright, so I’ve got a hack that allows me to do this, but it doesn’t feel clean or pretty or even error-free, but I think it’ll work for me until I know of a better way.

I’ve basically gone ahead and implemented a JobFilter that will add additional arguments based on the current context (which I track by wrapping my call to Enqueue() inside of a using(JobParameterTracker …) which holds a ThreadStatic variable, which my base job class can then read from later.

Definitely still looking for a better way to do this though.