LinqSampleDataContext context = new LinqSampleDataContext();
System.Data.Common.DbTransaction trans = null;
try

{
context.Connection.Open();
trans = context.Connection.BeginTransaction();
context.Transaction = trans;
context.Employees.InsertOnSubmit(emp);
context.SubmitChanges();
trans.Commit();
}
catch (Exception ex)

{
if (trans != null)
{
trans.Rollback();
}
}
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
try
{
for (int i = 0; i < nominees.Count; ++i)
{
Backup newBackup = nominees[i];
Ticket ticket = tickets[i];
//update the information of ticket
//mainly add the information of employee;
ticket.EmployeeID = newBackup.EmployeeID;
ticket.HaveNominated = true;
ticket.IsConfirmedByManager = true;
ticket.Status = TicketStatus.Enroll.ToString();
ticketAccessor.Update(ticket);
}
//update the IsSubmit of backup;
ChangeSubmitStatue(backup);
//remove the record of nominee in backup table
Delete(nominees);
}
catch (Exception ex)
{
ThrowHelper.ThrowBackupException("Finalizing occurs an error. The transcation will be rollback.");
return false;
}
scope.Complete();
}| Configuration Option | Default Value | Recommended Value |
|---|---|---|
|
Network DTC Access |
Disabled |
Enabled |
|
Client and Administration |
|
|
|
Allow Remote Clients |
Disabled |
Disabled |
|
Allow Remote Administration |
Disabled |
Disabled |
|
Transaction Manager Communication |
|
|
|
Allow Inbound |
Disabled |
Enabled |
|
Allow Outbound |
Disabled |
Enabled |
|
Mutual Authentication Required |
Enabled |
Enabled if all remote machines are running Win2K3 SP1 or XP SP2 or higher, and are configured with “Mutual Authentication Required”. |
|
Incoming Caller Authentication Required |
Disabled |
Enabled if running MSDTC on cluster. |
|
No Authentication Required |
Disabled |
Enabled if remote machines are pre-Windows Server 2003 SP1 or pre- Windows XP SP2. |
|
Enable TIP |
Disabled |
Enabled if running the BAM Portal. |
|
Enable XA Transactions |
Disabled |
Enabled if communicating with an XA based transactional system such as when communicating with IBM WebSphere MQ using the MQSeries adapter. |

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13770856/viewspace-410186/ ,如需转载,请注明出处,否则将追究法律责任。