Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on how you have set up your data contract.</p> <p>In WCF, using all the defaults, your service will use the DataContractSerializer (DCS) to serialize your object into XML. The DCS will serialize your fields in order - first the public ones, then the private ones. Within each visibility group, it will order the fields/properties alphabetically by name.</p> <p>Thus, if you introduce a new public property <code>MiddleName</code> and you already had <code>FirstName</code> and <code>LastName</code>, you would be fine: the old XML would have been</p> <pre><code>&lt;YourObject&gt; .... &lt;FirstName&gt;.....&lt;/FirstName&gt; &lt;LastName&gt;.....&lt;/LastName&gt; &lt;/YourObject&gt; </code></pre> <p>and your new one would just simply add a new property at the end:</p> <pre><code>&lt;YourObject&gt; .... &lt;FirstName&gt;.....&lt;/FirstName&gt; &lt;LastName&gt;.....&lt;/LastName&gt; &lt;MiddleName&gt;....&lt;/MiddleName&gt; &lt;/YourObject&gt; </code></pre> <p>Such an update "add something at the end" should work just fine, the DCS will just simply ignore additional tags in the XML. </p> <p>However: had you introduced a property called <code>Gender</code>, that would be stuck <strong>between</strong> <code>&lt;FirstName&gt;</code> and <code>&lt;LastName&gt;</code> and would thus break the order of the data in your XML and thus would break the data contract - no "old" client will be able to call your new service.</p> <p>In order to take control of this, you can put specific <code>Order=</code> attributes on your data members in your data contract:</p> <pre><code>[DataContract] public class SomeAddress { [DataMember(Order=0)] public string FirstName; [DataMember(Order=1)] public string LastName; } </code></pre> <p>Then you could easily add a new property - just add it to the end of the list!</p> <pre><code>[DataContract] public class SomeAddress { [DataMember(Order=0)] public string FirstName; [DataMember(Order=1)] public string LastName; [DataMember(Order=2)] public string Gender; } </code></pre> <p>So by using the <code>Order=</code> attribute on your data contracts, you can take control of your XML layout, and you can make simple extensions of existing data contracts non-breaking updates.</p> <p>For more background and in-depth know-how, you ought to read <a href="https://web.archive.org/web/20140519204507/http://msdn.microsoft.com:80/en-us/magazine/cc163569.aspx" rel="nofollow noreferrer">Serialization in Windows Communication Foundation</a> on MSDN Magazine's web site - highly recommended.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload