Reputation: 289
Hi I have class to sen via ria service. class look like
[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);
}
}
The problem is that when I recive object to client it's not ok. It always as a Children contain itself. Problem is on List of same type. Help?
Tnx!!
Upvotes: 0
Views: 718
Reputation: 522
I suppose this is some kind of parent-child tree structure.
The Association tag is used to say "this key" and "other key".
Your AttributeNode class needs a Id property to tell which its parent.
You'd need
[Key]
public int Uid { get; set; }
public int ParentUid { get; set; }
[Include]
[Association("AttributeNode_AttributeNode", "Uid", "ParentUid")]
public List<AttributeNode> Children { get; set; }
Upvotes: 2