I’m using hangfire for bulk data deletion job. Here is my code below:
public class JobScheduler: IScheduler
{
private BackgroundJobClient client;
private MyDao dao;
public JobScheduler(MyDao daoObj)
{
this.dao= daoObj;
this.client = new BackgroundJobClient();
}
public string EnqueueJob(IRequestMessage message)
{
return client.Enqueue(() => dao.BulkDelete(requestMsg));
}
}
}
public class MyDao: IDao
{
private readonly string connectionString;
public MyDao(string connectionString)
{
this.connectionString = connectionString;
}
public void BulkDelete(IRequestMessage message)
{
// My delete operation here..
}
}
http://docs.hangfire.io/en/latest/background-methods/using-ioc-containers.html
Followed as mention in the documentation to inject the dependency. I m using Unity Container for IoC.
I m still getting this error:
System.MissingMethodException
No parameterless constructor defined for this object.