_context = new DataContext(conn);
public void BeginTrans()
{
if (_context.Connection.State == System.Data.ConnectionState.Closed)
_context.Connection.Open();
_context.Transaction = _context.Connection.BeginTransaction();
}
public void CommitTrans()
{
if (_context.Transaction != null)
_context.Transaction.Commit();
_context.Connection.Close();
}
public void RollBackTrans()
{
if (_context.Transaction != null)
_context.Transaction.Rollback();
_context.Connection.Close();
}
来自:http://social.microsoft.com/Forums/fr-FR/adonetzhchs/thread/57fe8efe-61f4-47e4-9f06-fdcee7673637