Accessing Repository from IBackgroundTask implementation

Topics: Customizing Orchard, Writing modules
May 21, 2012 at 11:29 PM

Apologies as this is probably a beginner question.

We are trying to implement an IBackgroundTask that will read some database records and then update other records based on what is read.

We have the core mechanics of the IBackgroundTask implementation working.  The problem is that we don't have a pointer to the repository object within the Sweep method.

As I understand it, we would pass the repository or a wrapper for it into the constructor for the BackgroundTask constructor.  Unfortunately, I wasn't able to find any documentation or clear examples of how my constructor gets called, or where I would instantiate/store the arguments that need to be passed in.

Hopefully that was clear.  I appreciate any suggestions or pointers you can offer.



May 22, 2012 at 2:41 PM

Hey Scott,

I believe what you have to do is pass an IRepository<T> object into the Task constructor where T is the PartRecord of the Part whose database you are trying to access. Someone correct me if I'm wrong, but I think should do the trick!