2010-07-01 104 views
0

嗨我有通过ria服务sen。 类的样子通过ria服务发送自定义DTO

[DataContract] 
public partial class AttributeNode 
{ 
    [DataMember] 
    [Key] 
    public int Uid { get; set; } 

    public AttributeNode() 
    { 
     this.Children = new List<String>(); 
    } 

    private String text; 

    [DataMember] 
    public String Text 
    { 
     get 
     { 
      return text; 
     } 
     set 
     { 
      text = value; 
      this.Uid = text.GetHashCode(); 
     } 
    } 

    [DataMember] 
    [Include] 
    [Association("AttributeNode_AttributeNode", "Uid", "Uid")] 
    public List<AttributeNode> Children { get; set; } 

    public void AddChild(AttributeNode child) 
    { 
     this.Children.Add(child); 
    } 
} 

的问题是,当我recive目标客户这也不行。它总是作为一个孩子包含自己。问题在同一类型的列表上。帮帮我?

Tnx !!

回答

2

我想这是某种亲子树结构。

关联标签用于说“此密钥”和“其他密钥”。

您的AttributeNode类需要一个Id属性来告知它的父级。

你会需要

[Key] 
public int Uid { get; set; } 
public int ParentUid { get; set; } 


[Include] 
[Association("AttributeNode_AttributeNode", "Uid", "ParentUid")] 
public List<AttributeNode> Children { get; set; }