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; } } }
本文来自博客园,作者:WantRemake,转载请注明原文链接:https://www.cnblogs.com/SmallChen/p/17568799.html