views:

696

answers:

1

I'm using Visual Studio 2010 Beta 2 to learn to use Workflow Foundation (WF) version 4.0 prior to the upcoming release of Visual Studio 2010. One thing I've noticed is that if I persist a Workflow in the SQL Database persistence store, and then load it back into the application later and complete the workflow, the record is removed from the persistence store when the last activity of the workflow completes. I need to find out if this functionality is by design to keep the database from getting huge, or if I'm doing something wrong.

+2  A: 

This delete behavior is configurable. For example, if you are using the WorkflowServiceHost and are using code to configure your service host, you could set the SqlWorkflowInstanceStoreBehavior.InstanceCompletionAction to InstanceCompletionAction.DeleteNothing as in the following example:

WorkflowServiceHost host = new WorkflowServiceHost(workflow, baseAddress);
SqlWorkflowInstanceStoreBehavior persistenceBehavior = new SqlWorkflowInstanceStoreBehavior(connString);
persistenceBehavior.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;
host.Description.Behaviors.Add(persistenceBehavior);

For more information on features of the SQL workflow instance store and how you can configure it, check out this MSDN article.

Chris Gillum