Fork me on GitHub

C# 将一个list集合部分字段加入另一个集合 Select使用

 SubmitUserInfoRequestDto responseDto = new SubmitUserInfoRequestDto()
                {
                     id = item.NodeId,
                     name = item.NodeName
                };

                var userList = SMZX_ApprovalMember.GetList(item.NodeId);

                responseDto.child = userList.Select(x => new SubmitUserInfoRequestDto.Users() {
                    value1 = x.DepartmentId.Value,
                    value2 = x.MenberId.Value
                }).ToList();

public class SubmitUserInfoRequestDto { public int id { get; set; } public string name { get; set; } public List<Users> child { get; set; } public class Users { public int value1 { get; set; } public int value2 { get; set; } } }
posted @ 2023-07-20 16:35  WantRemake  阅读(554)  评论(0编辑  收藏  举报