Model赋值返回json
DataTable resultList = bll.GetResultListByCondition(bureauCode, deptCode, fileTitle);
IList<GanBuTianChengTongZhiGuanLiResultViewModel> list = new List<GanBuTianChengTongZhiGuanLiResultViewModel>();
//遍历行对象
foreach (DataRow drEntry in resultList.Rows)
{
GanBuTianChengTongZhiGuanLiResultViewModel resultModel = new GanBuTianChengTongZhiGuanLiResultViewModel();
PropertyInfo[] propertys = resultModel.GetType().GetProperties();
foreach (PropertyInfo item in propertys)
{
item.SetValue(resultModel, drEntry[item.Name].ToString(), null);
}
list.Add(resultModel);
}
jsonResult = new JavaScriptSerializer().Serialize(list);
return jsonResult;