linq to sql 的DataContext的 ExecuteCommand()方法

  _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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章