Persistence (msdn ):
Instanceview class: indicates an instance view. For example, the execute (instancehandle, instancepersistencecommand, timespan) method can return an instanceview object that provides a view of instance data in the permanent storage area.
Each instanceview object is associated with instancehandle. For instanceview returned from instancestore. Execute, the associated handle is the handle passed to execute. For instanceview returned from instancepersistencecontext. instanceview, the associated handle is the handle passed to trycommand.
At any given time, instancehandle can have 0 or more associated instanceview objects. The instanceview object returned from instancestore. Execute is unchangeable and indicates that snapshots of the Instance status are known after the command is successfully executed. The instanceview object returned from instancepersistencecontext is mutable and indicates the status of the currently known instance because it will be updated continuously during the execution of this command. (If the command fails, the intermediate state is discarded ).
public InstanceView Execute(InstanceHandle handle,InstancePersistenceCommand command,TimeSpan timeout)
-
Handle
-
Type: system. runtime. durableinstancing. instancehandle
An instance handle.
-
Command
-
Type: system. runtime. durableinstancing. instancepersistencecommand
The command to be executed.
-
Timeout
-
Type: system. timespan
The timeout value for this operation.
Return Value Type: system. runtime. durableinstancing. instanceview
An instanceview object, indicating the known status of the instance after the command is successfully completed. If execute is called in a transaction, this status can contain uncommitted data. Once the transaction is successfully committed, the data in the instanceview object is considered to have been committed. For example:
static InstanceStore instanceStore;
instanceStore = new SqlWorkflowInstanceStore(@"Data Source=.;Initial Catalog=WF4;uid=sa;pwd=123456;Asynchronous Processing=True");
InstanceHandle handle = instanceStore.CreateInstanceHandle();
InstanceView view = instanceStore.Execute(handle, new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
handle.Free();
instanceStore.DefaultInstanceOwner = view.InstanceOwner;
...........
application.InstanceStore = instanceStore;