Would this be an appropriate solution?
Using the FilePersistence.cs custom persistence handler I discovered within the download link on the following article:
http://msdn.microsoft.com/en-us/library/ms741725%28v=VS.85%29.aspx
public class FilePersistenceService : WorkflowPersistenceService
{
public FilePersistenceService(bool unloadOnIdle)
{
// ...
}
protected override void SaveWorkflowInstanceState(Activity rootActivity, bool unlock)
{
// ...
}
private void ReloadWorkflow(object id)
{
// ...
}
protected override Activity LoadWorkflowInstanceState(Guid instanceId)
{
// ...
}
protected override void UnlockWorkflowInstanceState(Activity state)
{
// ...
}
protected override void SaveCompletedContextActivity(Activity activity)
{
// ...
}
protected override Activity LoadCompletedContextActivity(Guid activityId, Activity outerActivity)
{
// ...
}
protected override bool UnloadOnIdle(Activity activity)
{
// ...
}
private void SerializeToFile(byte[] workflowBytes, Guid id)
{
// ... Direct workflowBytes to DB, indexed by Guid
}
private byte[] DeserializeFromFile(Guid id)
{
// ... Load bytes from DB, by Guid
}
}
... overriding the SerializeToFile and DeserializeFromFile to redirect the calls into a DB rather than the filesystem.
I would probably use NHibernate to accomplish the loading/saving - to keep my DAL common across the application, and hopefully keep DB independence (should it be required to use another DB platform).
Are there any major flaws to this plan?