Select from following answers:- Add a call to the Complete method of the TransactionScope after the call to SubmitChanges.
- Add a call to the Refresh method of the DataContext after the call to the SubmitChanges method.
- Add a call to the Complete method of the TransactionScope before the call to SubmitChanges.
- All Above
You can call LINQ to SQL APIs (including, but not limited to, SubmitChanges) in the scope of an active Transaction. LINQ to SQL detects that the call is in the scope of a transaction and does not create a new transaction. LINQ to SQL also avoids closing the connection in this case. You can perform query and SubmitChanges executions in the context of such a transaction. To complete the transaction and persist changes made with SubmitChanges, you must call the Complete method of the TransactionScope after calling the SubmitChanges method.
You must call the TransactionScope's Complete method after, not before, the call to SubmitChanges to ensure that the changes occur in the scope of the transaction.
The DataContext Refresh method refreshes object state by using data in the database. This method does not complete the transaction in scope, and calling this method after the call to the SubmitChanges method will not fix the problem.
Show Correct Answer
Source: MeasureUp.Com | |
Alert Moderator