How to pass a Strongly-Typed Dataset to a workflow

Hi,
Can anyone tell me how to pass multiple parameters one being a strongly-typed dataset to a workflow. It would be good it I could pass the dataset by reference too

What I'm trying to achieve is two-way communication between the host and the workflow via a dataset. There doesn't seem to be many examples of this on the web - can anyone help

Thanks!



Answer this question

How to pass a Strongly-Typed Dataset to a workflow

  • EricCS07

    Since the DataSet is serializable, you should be able to add it as a parameter to the workflow.  In Beta1, you can access this data from your workflow using the Parameters collection.  Once the workflow completes you can also read the parameter values from the event args in the WorkflowCompleted handler.

    There is no way to pass the dataset by reference; see this thread for more details: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=153587&SiteID=1 .  The main reason this doesn't work in our model is because when a workflow is unloaded by the runtime, and removed from memory, any host-references to workflow-instance specific data would be invalidated.

    If you want more sophisticated communication between the host and workflow instance, you should take a look at the EventSink and InvokeMethod activities, there are several samples included in the SDK.


    Arjun

  • tim.rachel

    The 'Ref' Parameter type in workflow is somewhat misleading, in that it doesn't actually mean you are passing the object by reference.  What it means is that you can read the parameter again, after the workflow completes, using the OutputParameters collection (which is passed in the event args of the WorkflowCompleted handler).

    Otherwise, you're definitely on the right track.  The Datasource activies and the IDataHandler interface have been removed from Beta2, so I'd suggest sticking with EventSink/MethodInvoke.  Alternatively, if you want to host the workflow in ASP.NET and expose it as a webservice, you can take a look at the WSReceive/Response activities.

    Hope this helps.
    Arjun


  • martinez1

    Hi Arjun,
    Thanks for the information. I added a parameter to the workflow's parameters collection of type MyStrongTypedDataset. I also changed the direction to Ref which leads me to believe that passing by reference is acceptable. However, you say that when a workflow is unloaded any host references are invalidated. If this is so is it unsafe for the parameters window to support passing parameters by Ref
    I will take a look at the EventSink and InvokeMethod activites to see how they can support my requirement. I also looked into implementing IDataHandler in a wrapper class that exposed the dataset but I couldn't get my head around it as the examples for IDataHandler a few and far between. Do you have any ideas on how best to pass my applications business objects (they expose a dataset) in and out of workflows

    Thanks,
    Martin

  • How to pass a Strongly-Typed Dataset to a workflow