SqlWorkflowPersistenceService Class



This API is now obsolete.

Represents a persistence service that uses a SQL database to store workflow state information.

public ref class SqlWorkflowPersistenceService : System::Workflow::Runtime::Hosting::WorkflowPersistenceService, System::Workflow::Runtime::IPendingWork
public class SqlWorkflowPersistenceService : System.Workflow.Runtime.Hosting.WorkflowPersistenceService, System.Workflow.Runtime.IPendingWork
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class SqlWorkflowPersistenceService : System.Workflow.Runtime.Hosting.WorkflowPersistenceService, System.Workflow.Runtime.IPendingWork
type SqlWorkflowPersistenceService = class
    inherit WorkflowPersistenceService
    interface IPendingWork
Public Class SqlWorkflowPersistenceService
Inherits WorkflowPersistenceService
Implements IPendingWork



This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

The SqlWorkflowPersistenceService class represents a fully-functional persistence service. You can use this service out-of-box to persist and retrieve workflow state information about a workflow instance when requested to by the workflow runtime engine.

The SqlWorkflowPersistenceService participates in the workflow transaction batching functionality provided by the WorkflowCommitWorkBatchService. That is, it adds objects that represent pending writes to the SQL database to the WorkBatch and implements the IPendingWork interface.

The SqlWorkflowPersistenceService supports locking of workflow instances. This feature is used when several workflow runtimes share the same database. A column in the SQL database table is used to mark a workflow instance as locked whenever it is being used by a workflow runtime. The SqlWorkflowPersistenceService does not load a workflow instance that is marked as "in use" by another runtime. Typically these locks are released when the workflow instance is persisted, for example, on idle, completion, or termination. The locks can also be released automatically after a period of inactivity. This period of inactivity can be set using the constructor of the SqlWorkflowPersistenceService class. It can also be set through the configuration file.

For more information about persistence services in general, see the WorkflowPersistenceService class.

Workflow instances can contain timers, for example, if they have a DelayActivity. For workflows that contain timers, the SqlWorkflowPersistenceService records the time when the workflow's next timer expires. The SqlWorkflowPersistenceService periodically polls the database, looking for workflows whose timers have expired. The frequency of the polling interval can be set using the SqlWorkflowPersistenceService constructor or using a configuration file.


When using both the SqlTrackingService and the SqlWorkflowPersistenceService in a workflow application, it is recommended to use a single database for both persistence and tracking.



Initializes a new instance of the SqlWorkflowPersistenceService class by using the specified parameters.


Initializes a new instance of the SqlWorkflowPersistenceService class by using the database connection string.

SqlWorkflowPersistenceService(String, Boolean, TimeSpan, TimeSpan)

Initializes a new instance of the SqlWorkflowPersistenceService class using a database connection string and other parameters.



Gets or sets a value that specifies whether the SqlWorkflowPersistenceService retries committing a work batch.


Gets the length of the loading interval.


Gets the WorkflowRuntime for this service.

(Inherited from WorkflowRuntimeService)

Gets the service instance identifier.


Gets the state of the WorkflowRuntimeService.

(Inherited from WorkflowRuntimeService)



Determines whether the specified object is equal to the current object.

(Inherited from Object)

Retrieves instance descriptions of all persisted workflows.


Serves as the default hash function.

(Inherited from Object)

Gets the Type of the current instance.

(Inherited from Object)
LoadCompletedContextActivity(Guid, Activity)

Retrieves the specified completed scope from the database.


Retrieves a list of ids for workflows with expired timers.


Retrieves the specified workflow instance state from the database.


Creates a shallow copy of the current Object.

(Inherited from Object)

Starts a new timer and recovers running workflow instances.


When overridden in a derived class, represents the method that will be called when the workflow runtime engine raises the Stopped event.

(Inherited from WorkflowRuntimeService)
RaiseServicesExceptionNotHandledEvent(Exception, Guid)

Raises the ServicesExceptionNotHandled event.

(Inherited from WorkflowRuntimeService)

Saves the state of the specified completed scope.

SaveWorkflowInstanceState(Activity, Boolean)

Saves the specified workflow instance state.


Starts the SqlWorkflowPersistenceService.


Stops the service and the timer.


Returns a string that represents the current object.

(Inherited from Object)

Returns a value that indicates whether the workflow is unloaded when it is in an idle state.


Unlocks access to the specified workflow instance state.

Explicit Interface Implementations

IPendingWork.Commit(Transaction, ICollection)

Writes an ICollection of serialized state objects to the database.

IPendingWork.Complete(Boolean, ICollection)

Completes the work batch and releases any resources.


Returns a value that indicates whether the collection of serialized state objects should be written to the database.

Applies to