DSP

c#中dataset存取

2019-07-13 15:13发布

           [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 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(id);
            IList 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中