How do I add Items to PerformContext Item collection?


#1

I see there is an Items collection in the PerformContext but I have dug around the documentation and the forum and can’t find any mention as to how to add items to the collection.

My hope is that there’s a way to specify an item to be added when the job is scheduled.


#2

You can only add items to collections when you implement a custom job filter and it’s only meant to be used for passing around items between filter events. I had something similar requirements where I wanted to pass job parameters outside method signature which hangfire automatically adds, but cannot do such a thing. The only work around is to make your method param a dictionary or something generic and then you can pass a collection of items just like you do console app.


#3

Thanks. I have a filter that sets the security principal and I thought it would be nice to be able to specify what principal I wanted to use when defining the job.