Model賦值返回json

 

 

 DataTable resultList = bll.GetResultListByCondition(bureauCode, deptCode, fileTitle);json

        IList<GanBuTianChengTongZhiGuanLiResultViewModel> list = new List<GanBuTianChengTongZhiGuanLiResultViewModel>();對象

        //遍歷行對象        ip

foreach (DataRow drEntry in resultList.Rows)        it

{            io

GanBuTianChengTongZhiGuanLiResultViewModel resultModel = new GanBuTianChengTongZhiGuanLiResultViewModel();foreach

            PropertyInfo[] propertys = resultModel.GetType().GetProperties();                           List

          foreach (PropertyInfo item in propertys)            file

   {            遍歷

                            item.SetValue(resultModel, drEntry[item.Name].ToString(), null);     di

        }

            list.Add(resultModel);    

     }

        jsonResult = new JavaScriptSerializer().Serialize(list);

        return jsonResult;

相關文章
相關標籤/搜索