1、从数据库获取DataTable类型:
DataTable dt = DBConn.GetPageList(pageIndex, pageSize, "select * from erp_process" + pageSort, ref rowCount);
2、DataTable转换为var类型:
var query = from p in dt.AsEnumerable()
select new
{
ID = int.Parse(p["ID"].ToString()),
ProcessCode = p["ProcessCode"].ToString(),
ProcessName = p["ProcessName"].ToString(),
ProcessType = p["ProcessType"].ToString(),
ProcessMan = p["ProcessMan"].ToString(),
ProcessTypeName = TypeMapping(p["ProcessType"].ToString()),
ProcessManName = ManMapping(p["ProcessMan"].ToString())
};
3、返回JsonResult类型:
Json(new { rows = query, total = rowCount }, JsonRequestBehavior.AllowGet);