Which code segment should you use?

You create a Windows Workflow Foundation application by using Microsoft .NET Framework 3.5. You add a class to the workflow that implements the IPendingWork interface. The class interacts with a Microsoft SQL Server 2005 database. All database write operations must be performed in a transaction. You implement a Commit method of the IPendingWork interface. You need to complete the Commit method. Which code segment should you use?

You create a Windows Workflow Foundation application by using Microsoft .NET Framework 3.5. You add a class to the workflow that implements the IPendingWork interface. The class interacts with a Microsoft SQL Server 2005 database. All database write operations must be performed in a transaction. You implement a Commit method of the IPendingWork interface. You need to complete the Commit method. Which code segment should you use?

A.
public void Commit(Transaction trans, ICollection items) { SqlConnection con = new SqlConnection("<con str>"); con.BeginTransaction(); …}

B.
public void Commit(Transaction trans, ICollection items) { SqlConnection con = new SqlConnection("<con str>"); con.EnlistTransaction(trans); …}

C.
public void Commit(Transaction trans, ICollection items) { SqlConnection con = new SqlConnection("<con str>"); con.EnlistTransaction(new CommittableTransaction()); …}

D.
public void Commit(Transaction trans, ICollection items) { using (TransactionScope tscope=new TransactionScope()) { SqlConnection con = new SqlConnection("<con str>"); … tscope.Complete(); }}



Leave a Reply 0

Your email address will not be published. Required fields are marked *