前提需要替换查询得到的List当中的某个字段的值,替换规则有一个mapping关系
尝试代码 有问题 无法获取任何数据
class="code_img_closed" src="/Upload/Images/2013080118/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('c2c1b816-f921-4a07-81ac-641db159cd9a',event)" src="/Upload/Images/2013080118/2B1B950FA3DF188F.gif" alt="" />1 /// <summary> 2 /// 获取Treegrid的List 3 /// </summary> 4 /// <returns></returns> 5 public JsonResult GetOrgnizationList() 6 { 7 IQueryable<Rights_Sys_Organization> list = db.Rights_Sys_Organization; 8 return Json(new treegrid 9 { 10 rows = list.Select( 11 s => new 12 { 13 _parentId = s.ParentCode, 14 OrganizationName = s.OrganizationName, 15 EnglishName = s.EnglishName, 16 OrganizationType = s.OrganizationType, 17 States = SysDictionaryCollection.GetFieldTextByDicTypeAndValue("DicType",s.States), 18 OrganizationCode = s.OrganizationCode, 19 Order = s.Order 20 }).OrderBy(c => c.Order) 21 }, JsonRequestBehavior.AllowGet); 22 }View Code
正常的代码
1 /// <summary> 2 /// 获取Treegrid的List 3 /// </summary> 4 /// <returns></returns> 5 public JsonResult GetOrgnizationList() 6 { 7 IQueryable<Rights_Sys_Organization> list = db.Rights_Sys_Organization; 8 return Json(new treegrid 9 { 10 rows = list.Select( 11 s => new 12 { 13 _parentId = s.ParentCode, 14 OrganizationName = s.OrganizationName, 15 EnglishName = s.EnglishName, 16 OrganizationType = s.OrganizationType, 17 States = s.States, 18 OrganizationCode = s.OrganizationCode, 19 Order = s.Order 20 }).OrderBy(c => c.Order) 21 }, JsonRequestBehavior.AllowGet); 22 }View Code
暂时未找到解决办法 如果有人知道怎么解决请留言 谢谢!