linq批量更新实体数据

logs = logs.Select(p =>
                        {
                            p.RecordID = recordID;
                            p.FileSourceType = 2;
                            p.CreateTime = DateTime.Now;
                            return p;
                        }).ToList();
#region 根据组织机构用户姓名获取用户信息
        /// 
        /// 根据组织机构用户姓名获取用户信息
        /// 
        /// 
        /// 
        /// 
        [HttpGet]
        public JsonResult GetUserInfo(string orgCode,string userName)
        {
            List rltList = new List();
            var rlt = _org.GetUserInfo(orgCode, userName);
            if(rlt!=null&&rlt.Count()>0)
            {
                //rlt.ToList().ForEach(s=> s.IsOrgManager = s.OrgManagerUserID==s.UserID);

                var group = from s in rlt
                            group s by s.UserID;
                foreach (var g in group)
                {
                    RltOrgUserModel rltOrgUserModel = _mapper.Map(g.ToList()[0]);
                    List roleID = new List();
                    rltOrgUserModel = g.ToList().Select(p => 
                    { 
                        rltOrgUserModel.RoleNames += p.RoleName;
                        roleID.Add(p.ID);
                        rltOrgUserModel.IsOrgManager = p.OrgManagerUserID == p.UserID;
                        return rltOrgUserModel;
                    }).ToList().FirstOrDefault();
                    rltOrgUserModel.RoleID = roleID;
                    rltList.Add(rltOrgUserModel);
                }
            }
            return JsonResultExt.Success(rltList);
        }

        #endregion

 

你可能感兴趣的:(linq,c#)