c#中dataset存取

 

         [WebMethod]
        public DataSet GetLineByID(long id)
        {
            IndexCommonBasePage basePage = new IndexCommonBasePage();
            string json = string.Empty;
            var dsPole = new DataSet();
            var dtPole = new DataTable();
            dtPole.Columns.Add("Name", typeof(string));
            dtPole.Columns.Add("PoleTypeValue", typeof(string));
            dtPole.Columns.Add("ID", typeof(long));
            dtPole.Columns.Add("AngleDirection.Value", typeof(string));
            dtPole.Columns.Add("AngleDegree", typeof(decimal));
            dtPole.Columns.Add("PoleDistance", typeof(decimal));
            dtPole.Columns.Add("SamePoleLoopNum", typeof(int));
            dtPole.Columns.Add("SeqNo", typeof(decimal));
            dtPole.Columns.Add("VoltageLevelValue", typeof(string));
            dtPole.Columns.Add("Line.ID", typeof(long));
            dsPole.Tables.Add(dtPole);
            Line item1 = basePage.BaseRecordService.GetLineById(id);
            IList<Pole> collectPole1 = basePage.DeviceService.GetPoles(id);
            if (collectPole1 != null && collectPole1.Count > 0)
            {
                foreach (Spf.Domain.Model.Pole i in collectPole1)
                {
                    Line line = new Line();
                    var drPole = dtPole.NewRow();
                    drPole[0] = i.Name;
                    drPole[1] = i.PoleTypeValue;
                    drPole[2] = i.ID;
                    drPole[3] = i.AngleDirection == null ? string.Empty : i.AngleDirection.Value;
                    drPole[4] = i.AngleDegree;
                    drPole[5] = i.PoleDistance;
                    drPole[6] = i.SamePoleLoopNum;
                    drPole[7] = i.SeqNo;
                    drPole[8] = i.VoltageLevelValue;
                    drPole[9] = i.Line == null ? 0 : i.Line.ID;
                    dtPole.Rows.Add(drPole);                   
                    GetPoleByID(i.ID);
                }
            }
            return dsPole;
        }
        [WebMethod]
        public DataSet GetPoleByID(long id)
        {
            IndexCommonBasePage basePage = new IndexCommonBasePage();
            var dsPole = new DataSet();
            var dtPole = new DataTable();
            dtPole.Columns.Add("Name", typeof(string));
            dtPole.Columns.Add("Pole.TypeValue", typeof(string));
            dtPole.Columns.Add("ID", typeof(long));
            dtPole.Columns.Add("AngleDirection.Value", typeof(string));
            dtPole.Columns.Add("AgnleDegree", typeof(decimal));
            dtPole.Columns.Add("Pole.PoleDistance", typeof(decimal));
            dtPole.Columns.Add("Pole.SamePoleLoopNum", typeof(int));
            dtPole.Columns.Add("VoltageLevelValue", typeof(string));
            dtPole.Columns.Add("Pole.ID", typeof(long));
            dsPole.Tables.Add(dtPole);
            Pole pole = basePage.BaseService.GetEntityById<Pole>(id);
            IList<Line> lineNew = pole.NewLines;
            if (lineNew.Count > 0)
            {
                foreach (Spf.Domain.Model.Line item in lineNew)
                {
                    var drPole = dtPole.NewRow();
                    drPole[0] = item.Name;
                    drPole[1] = item.Pole == null ? string.Empty : item.Pole.TypeValue;
                    drPole[2] = item.ID;
                    drPole[3] = item.AngleDirection == null ? string.Empty : item.AngleDirection.Value;
                    drPole[4] = item.Pole == null ? 0 : item.Pole.AngleDegree;
                    drPole[5] = item.Pole == null ? 0 : item.Pole.PoleDistance;
                    drPole[6] = item.Pole == null ? 0 : item.Pole.SamePoleLoopNum;
                    drPole[7] = item.VoltageLevelValue;
                    drPole[8] = item.Pole == null ? 0 : item.Pole.ID;
                    dtPole.Rows.Add(drPole);
                    GetLineByID(item.ID);
                }
            }
            return dsPole;
        }
    }

上面我是我在webservice中的源码,我想通过GetLineByID得到GetPoleByID中的数据,并填入GetLineByID的dataset中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值