O'Reilly logo

Microsoft Windows Workflow Foundation 4.0 Cookbook by Andrew Zhu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing a transaction by using TransactionScope activity

In this task, we will create a workflow with TransactionScope activity, in which a customized activity will insert some data in the database. If any exception/error occurs, the newly inserted data will be rolled back.

How to do it...

  1. Create a Workflow Console Application:

    Create a new Workflow Console Application and name it UseTransactionScope.

  2. Create a database for testing:

    Create a new database in SQL Server (or SQL Server Express) and name it TransactionDB. Use the following SQL statement to create a new table:

    create table UserTable(
    	UserID nvarchar(50) primary key
    )
  3. Add references to the project:

    Add a reference to the System.Tranactions namespace because we are going to use IsolationLevel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required