日期:2014-05-20  浏览次数:20970 次

entity framwork的TransactionScope事务回滚问题
public string ReceiveOrder(int custId, string xml){
      try
      {
          using (JXEntities jx = new JXEntities())
          {
              
              using (TransactionScope transaction = new TransactionScope())
              {
                  [color=#FF6600]jx.Connection.Open();[/color]                //加载
                  XmlDocument xmldoc = new XmlDocument();
                  xmldoc.LoadXml(xml);
                  XmlNode xmlOrderHead = xmldoc.SelectSingleNode("root");
                  string orderNo = "";
                  OrderHead o = new OrderHead();
                  if (xmlOrderHead != null)
                  {
                       try { remark = xmlOrderHead.SelectSingleNode("Remark").InnerText; }
                      catch { }
                      o.Remark = remark;
                  }
                   jx.OrderHeads.AddObject(o);
                      jx.SaveChanges();

                  XmlNodeList xmlOrderLine = xmlOrderHead.SelectNodes("lines");
                  OrderLine line = new OrderLine();
                  if (xmlOrderLine.Count > 0)
                  {
                      foreach (XmlNode node in xmlOrderLine)
                      {