You are implementing an application that uses LINQ to SQL to update a data source. You add the following code that uses a DataContext named northwindContext:

using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
Product prod1 = northwindContext.Products.First(p => p.ProductID == 4);
Product prod2 = northwindContext.Products.First(p => p.ProductID == 5);
prod1.UnitsInStock -= 3;
prod2.UnitsInStock -= 5;

This method is called by code that creates a transaction scope. You are debugging by stepping through this method. You notice that the data source is not updated after you step over the call to the Complete method. You need to ensure that the data source is updated.

What should you do?

 Posted by Rajkatie on 9/30/2012 | Category: ADO.NET Interview questions | Views: 1184 | Points: 40
Select from following answers:
  1. Use the TransactionScopeOption with RequiresNew or continue stepping through code until the Complete method is called on a root ambient transaction.
  2. Replace the call to the SubmitChanges method with a call to the DataContext's Refresh method.
  3. Call Complete before calling the SubmitChanges method.
  4. All Above

Show Correct Answer

Source: MeasureUp.Com | | Alert Moderator 

Comments or Responses

Login to post response