【发布时间】:2016-02-26 10:15:52
【问题描述】:
我有一个这样的列表(已经用 Visual Studio 调试器打开):
如您所见,该列表由相同类型列表的其他对象组成,我需要遍历所有子对象,而不考虑索引并验证 FID该对象的 em> 与 UI 传递的对象相同。一旦找到返回相同对象的匹配服务器。
我可以试试这个进行测试, 但考虑到我只有顶级项目,那些索引为 0 的项目,并没有全部流动:
AttachmentFolders childWithId17 = ApplicationContext.Instance.companyList[0].AttachmentFolders.SelectMany(parent => parent.AttachmentFolder)
.FirstOrDefault(child => child.FID == "835A09A2-9D60-46CC-A2BE-D4CBC4C81860");
另一张图更好理解
事实上,我得到了一个包含许多元素的列表,并且应该滚动所有元素,即使以响应方式能够返回与该 AttachmentFolders 对应的对象FID .
类结构:
public class AttachmentFolders
{
public int id { get; set; }
public String FID { get; set; }
public String Name { get; set; }
public String CPID { get; set; }
public String ParentFID { get; set; }
public List<Attachment> Attachments { get; set; }
public List<AttachmentFolders> AttachmentFolder { get; set; }
}
public class Attachment
{
public int id { get; set; }
public String ATID { get; set; }
public String Name { get; set; }
public String CreatorID { get; set; }
public String FID { get; set; }
public String Extension { get; set; }
public String Description { get; set; }
public int Status { get; set; }
public String CPID { get; set; }
public int FileSize { get; set; }
public DateTime CreationDate { get; set; }
public DateTime ModifiedDate { get; set; }
public int AttachmentType { get; set; }
public int ValidityType { get; set; }
public List<Revisions> Revisions { get; set; }
public String AWID { get; set; }
public String WAID { get; set; }
public String WatermarkPositions { get; set; }
public Boolean Serveroffline { get; set; }
public Boolean IsFavourite { get; set; }
public DateTime LastOpenDate { get; set; }
public int Priority { get; set; }
public String CreatorFirstName { get; set; }
public String CreatorLastName { get; set; }
public String ModifiedByFirstName { get; set; }
public String ModifiedByLastName { get; set; }
public String[] Capabilities { get; set; }
}
谢谢大家。
【问题讨论】:
-
我无法重新创建您的班级结构。您能告诉我们您的课程是如何设计的吗?
-
我已经添加了结构的两个类,谢谢
标签: c# list recursion parent-child