编程语言
首页 > 编程语言> > c# GroupBy分组 去重

c# GroupBy分组 去重

作者:互联网

/// <summary>
/// 根据 RoleID And SectionStr 获取 UserInfoList
/// </summary>
/// <returns></returns>
public ActionResult GetUserDataByRoleAndSection(UserInfoViewModel viewModel)
{

IList<UserInfo> userinfolist = _service.GetUserByRoleAndSection(viewModel);

var userListvalue = userinfolist.GroupBy(p => new { p.ID, p.TrueName }).Select(g => g.First()).ToList();

if (userinfolist != null)
{
return Json(new { flag = "success", userinfolist = userListvalue });
}

return Json(new { flag = "error" });

}

转载于:https://www.cnblogs.com/yibu/p/4788868.html

标签:return,c#,userinfolist,viewModel,Json,分组,userListvalue,new,GroupBy
来源: https://www.cnblogs.com/wl-blog/p/15545618.html