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())
{
Product prod1 = northwindContext.Products.First(p => p.ProductID == 4);
Product prod2 = northwindContext.Products.First(p => p.ProductID == 5);
prod1.UnitsInStock -= 3;
prod2.UnitsInStock -= 5;
northwindContext.SubmitChanges();
}

You notice that when this code executes the data source is not updated. You need to fix the problem and ensure that the data source changes execute in the scope of the transaction.

What should you do?

 Posted by Rajkatie on 9/30/2012 | Category: ADO.NET Interview questions | Views: 2327 | Points: 40
Select from following answers:
  1. Add a call to the Complete method of the TransactionScope after the call to SubmitChanges.
  2. Add a call to the Refresh method of the DataContext after the call to the SubmitChanges method.
  3. Add a call to the Complete method of the TransactionScope before the call to SubmitChanges.
  4. All Above

Show Correct Answer


Source: MeasureUp.Com | | Alert Moderator 

Comments or Responses

Login to post response