开发者

How to decide what does and doesn't get persisted in a workflow

开发者 https://www.devze.com 2023-03-11 23:19 出处:网络
I have a question with regards to persistence of value states in a persisted workflow. I have two properties inside one of my Extension classes:

I have a question with regards to persistence of value states in a persisted workflow. I have two properties inside one of my Extension classes:

    public int ApprovalCount
    {
        get;
        set;
    }

    public bool ApprovedByAllInitialApprovers
    {
        get;
        set;
    }

These properties are set during some calculations that take place on another method.

My problem is, when the workflow goes idle and persists, the state of these values is a开发者_StackOverflow中文版lso persisted to the database, so if I call the method on my extension class again, I am picking up the values as I left them; I understand this behaviour is obviously fairly fundamental to the way workflows operate in a persisted fashion and in 90% of cases I do want values to be remebered and persisted, but what about exceptions to this? Is there any way I can 'mark' a property (perhaps with an attribute) to indicate that I do not want it persisted? Or must I simply reset the values before I do my calculation each time?

Any help greatly appreciated. Thanks in advance.


There are two answers to this question.

  1. First of all when a workflow is serialized it is done so using the binary serializer. So you can mark any fields you don't want to serialize with the NonSerialized attribute.
  2. That said workflow extensions are not serialized during workflow persistence so you must be doing something interesting to get them to serialize. Or else you might be using a singleton extension and it and its values stay around even though the workflow is persisted and reloaded.
0

精彩评论

暂无评论...
验证码 换一张
取 消