我在数据库中有一个表,其结构如下:
ID | Process_Id | Attribute | Parent_Id | Sequence
----------------------------------------------------
1 1 INDIVIDUAL
2 1 FIRST_NAME 1 1 //parent_id is same as ID of its parent
3 1 SECOND_NAME 1 2
4 1 INDIVIDUAL_ALIAS 1
5 1 ALIAS_NAME 4 1
6 2 sdnEntry
7 2 firstName 6 1
8 2 lastName 6 2
9 2 aka 6
10 2 firstName 9 1
11 2 lastName 9 2
12 1 ENTITY
13 1 FIRST_NAME 12 1
14 1 ENTITY_ALIAS 12
15 1 ALIAS_NAME 14 1
我为这些数据设置值的类如下所示;
将我之前的代码更新为DataAdapter public class Attribute {public int ProcessId {get; 放; } public List ParentNodes {get; 放; }
}
public class ParentAttribute
{
public int id { get; set; }
public string parentNodeValue { get; set; }
public List<ChildAttribute> ChildNodeValues { get; set; }
}
public class ChildAttribute
{
public int sequence { get; set; }
public string childNodeValue { get; set; }
public int parentId { get; set; }
//public List<GrandChildAttribute> childNodeValue { get; set; }
}
public class GrandChildAttribute
{
public int sequence { get; set; }
public string grandChildNodeValue { get; set; }
public int parentId { get; set; }
}
现在,我可以在我的对象中放置值了,但是,问题是某些子节点具有单个值,而某些包含进一步的列表,我如何在运行时为该属性分配类型。在我当前的情况下,两个父节点“ INDIVIDUAL”和“ ENTITY”每个父节点都有自己的子节点(由parent_IdparentNodes的parent_Id标识)被认为是空的,进一步的子节点也有一些granchildnodes。
相关分类