WCF DataContract Serializer and IsReference property

One of the new features of .NET framework 3.5 SP1 is the possibility to serialize an object graph with circular references by using the standard xsd:ID/xsd:IDREF attributes.

Just mark your DataContract attribute with the IsReference=true property:

    [DataContract(IsReference=true)]

    public class Room

    {

        [DataMember]

        public string description { get; set; }

        [DataMember]

        public Devices roomDevices { get; set; }

    }

 Check out this post by Zulfiqar for more examples.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">