Circular reference

Hi,

I have a webmethod returning a "tree" but each node has a reference to its parent. But the XMLSerializer doesn't support circular references. Is it possible to return such circular reference types from webmerthods

Thanks,

Kostadin



Answer this question

Circular reference

  • ThomasJaeger

    XML, with its parent-child structure format, doesn't support circular references. What you can do is use the <XMLIgnore> attribute to prevent the XMlSerializer from the serializing that field, then on the client re-build the circular reference. http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlignoreattribute.aspx


    You could also use a dataset as it supports circular references, not through pointers (ByRef), but through PK/FK (integer) fields.

  • Circular reference