Introduction : The CompensateSequence Activity will provide compensation only if there is any error thrown. The CompensatableSequence Activity class inherits from Sequence Activity, it can contain any number of child activities that execute in order. Compensation logic is similar to a transaction. The difference is that a transaction locks the database until all updates are done, making it only suitable for short durations. A compensate action is used in long running transactions to undo the original transaction that was already committed.
- Compensate sequence class : public sealed class.
- CompensatableSequence Activity : Sequence Activity, ICompensatable Activity.
Step 1 : Open Visual Studio 2011.
- Go to File->New->Project.
- Select Sequential Workflow Console Application.

Step 2 : Now drag the activity from Toolbox.
- Select CompensatableSequenceActivity.
- Select Code Activity and Delay Activity below the CompensatableSequence Activity.

Step 3 : Right-click on CompensatableSequence Activity and go to Properties option.
- Give the Enabled Condition is "True".

Step 4 : Click in CompensatableSequence Activity and select View Compensation Handler because we can define the Executecode.
- Define the CodeActivity1 event inside the property of CodeActivty2.

Step 5 : Now go to the Workflow1.cs[Design] and select Sequential Workflow Application and right-click.
- Define the Completed and Initialized property.

Step 6 : Go to Workflow1.cs and write the below code.

Amit MaheshwarieditedPosted Nov 21, 2011, 4:03 PMEdited Nov 21, 2011, 4:04 PM
thanks davin it is really helpful for me. but you should have to give code explanation too
Deepak DwijPosted Nov 21, 2011, 4:03 PM
Its really a nice explanation Davin , u encourages me alot ! Thanks