locked
About InstanceView's InstanceMetadata property RRS feed

  • Question

  • I find the InstanceView class has  a InstanceMetadata property:

    public IDictionary<XName, InstanceValue> InstanceMetadata { get; internal set; }

    But it seems the property always is empty.

    When Start a workflow, there is a AddInitialInstanceValues method.

     

     // Add the WorkflowHostType value to workflow application so that 

    //it stores this data in the instance store when persisted

     wfApp.AddInitialInstanceValues(wfScope);            

     

    I think the WF4 provider a method to store some metadata with workflow instance, but how to store and access them?

    Monday, May 24, 2010 3:21 PM

Answers

  •             You could use following sample to update InstanceMetadata and InstanceData.

                SaveWorkflowCommand save = new SaveWorkflowCommand();
                save.InstanceMetadataChanges.Add(new KeyValuePair<XName,InstanceValue>(XName.Get("MD1", "TestNamespace"), new InstanceValue(1)));
                save.InstanceData.Add(new KeyValuePair<XName,InstanceValue>(XName.Get("D1", "TestNamespace"), new InstanceValue("fakeData")));
                save.CompleteInstance = false;
                save.UnlockInstance = true;
                store.Execute(handle, save, TimeSpan.FromSeconds(30));
                handle.Free();

    • Marked as answer by Andrew_Zhu Monday, May 31, 2010 2:27 AM
    Thursday, May 27, 2010 5:36 AM