2010-07-01 50 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; }