Writing and reading workflow from sql database RRS feed

  • Question

  • I'm working on my own workflow designer and runtime. For now, I'm storing the xaml files that contain my workflow into a folder so while executing my workflows I'm writing and loading from that folder. I want to change that and use a SQL Database instead.

    So, what are my options? Should the database have a specific format? Should I use Workflow persistence?

    • Edited by améni Friday, July 19, 2013 10:08 AM
    Friday, July 19, 2013 10:00 AM


  • The basic idea when you are using wf persistence is as follows:

    1. get the workflow identity of a runnable workflow (using the workflow instance guid)
    2. get the definition for that identity
    3. load the workflow state
    4. run.

    This is mostly covered by wf persistence except for step 2: getting the definition from the identity, this you have to implement yourself. How you do that is fully up to you, the only requirement is given an identity you must be able to provide a System.Activities.Activity instance that is the root of your workflow definition. You can do that pretty much any way you want e.g. hardwiring predefined workflows, parsing a file by XamlReader, parsing a string value from database by the same XamlReader, etc. Since you're taking the database path the simplest way would be to store the definitions in a table keyed by the identity fields (name, package, version), and the xaml file content as a basic varbinary field. Then you can use bare ado.net/your favorite ORM/whatever to manage it.

    Monday, July 22, 2013 9:36 PM