wcf - IsReference property in data contract -


What is the purpose of the DataContract property in the IsReference property? According to this property how do the requests and responses change?

Determines how objects are ordered, by default, IsReference = false . Setting isReference = true allows the serialization of an object tree that can reference one another. Therefore, with a list of employee that each has manager (which is also employee ), is a property for manager < Instead of embedding code> manager each employee node:

for each employee can be done. > Irferrance = false will be generated:

  & lt; Employee & gt; & Lt; Manager I: nil = "true" /> & Lt; Name & gt; Kenny & lt; / Name & gt; & Lt; / Staff & gt; & Lt; Employee & gt; & Lt; Manager & gt; & Lt; Manager I: nil = "true" /> & Lt; Name & gt; Kenny & lt; / Name & gt; & Lt; / Manager & gt; & Lt; Name & gt; Bob & lt; / Name & gt; & Lt; / Staff & gt; & Lt; Employee & gt; & Lt; Manager & gt; & Lt; Manager I: nil = "true" /> & Lt; Name & gt; Kenny & lt; / Name & gt; & Lt; / Manager & gt; & Lt; Name & gt; Alice & lt; / Name & gt; & Lt; / Staff & gt;  as IsReference = true  will be generated as: 

  employee z: id = "i1" xmlns: z = " Http://schemas.microsoft.com/2003/10/Serialization/"> & Lt; Manager I: nil = "true" /> & Lt; Name & gt; Kenny & lt; / Name & gt; & Lt; / Staff & gt; & Lt; Employee z: id = "i2" xmlns: z = "http://schemas.microsoft.com/2003/10/Serialization/" & gt; & Lt; Manager z: ref = "i1" /> & Lt; Name & gt; Bob & lt; / Name & gt; & Lt; / Staff & gt; & Lt; Employee z: id = "i3" xmlns: z = "http://schemas.microsoft.com/2003/10/Serialization/" & gt; & Lt; Manager z: ref = "i1" /> & Lt; Name & gt; Alice & lt; / Name & gt; & Lt; / Staff & gt;  

A snippet from which the full description is given with examples of XML generated with the property.

MSDN - Provides details as well


Comments