title: WCF service proxy not setting "FieldSpecified" property
body: <p>I've got a WCF <code>DataContract</code> that looks like the following:</p>
  
  <pre><code>namespace MyCompanyName.Services.Wcf
  {
    [DataContract(Namespace = "http://mycompanyname/services/wcf")]
    [Serializable]
    public class DataContractBase
    {
      [DataMember]
      public DateTime EditDate { get; set; }
  
      // code omitted for brevity...
    }
  }
  </code></pre>
  
  <p>When I add a reference to this service in Visual Studio, this proxy code is generated:</p>
  
  <pre><code>/// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://mycompanyname/services/wcf")]
  public partial class DataContractBase : object, System.ComponentModel.INotifyPropertyChanged {
  
      private System.DateTime editDateField;
  
      private bool editDateFieldSpecified;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Order=0)]
      public System.DateTime EditDate {
          get {
              return this.editDateField;
          }
          set {
              this.editDateField = value;
              this.RaisePropertyChanged("EditDate");
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlIgnoreAttribute()]
      public bool EditDateSpecified {
          get {
              return this.editDateFieldSpecified;
          }
          set {
              this.editDateFieldSpecified = value;
              this.RaisePropertyChanged("EditDateSpecified");
          }
      }
  
      // code omitted for brevity...
  }
  </code></pre>
  
  <p>As you can see, besides generating a backing property for <code>EditDate</code>, an additional <code>&lt;propertyname&gt;Specified</code> property is generated. All good, except that when I do the following:</p>
  
  <pre><code>DataContractBase myDataContract = new DataContractBase();
  myDataContract.EditDate = DateTime.Now;
  
  new MyServiceClient.Update(new UpdateRequest(myDataContract));
  </code></pre>
  
  <p>the <code>EditDate</code> was not getting picked up by the endpoint of the service (does not appear in the transmitted XML).</p>
  
  <p>I debugged the code and found that, although I was setting <code>EditDate</code>, the <code>EditDateSpecified</code> property wasn't being set to <code>true</code> as I would expect; hence, the XML serializer was ignoring the value of <code>EditDate</code>, even though it's set to a valid value.</p>
  
  <p>As a quick hack I modified the <code>EditDate</code> property to look like the following:</p>
  
  <pre><code>   /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Order=0)]
      public System.DateTime EditDate {
          get {
              return this.editDateField;
          }
          set {
              this.editDateField = value;
  
              // hackhackhack
              if (value != default(System.DateTime))
              {
                this.EditDateSpecified = true;
              }
              // end hackhackhack
  
              this.RaisePropertyChanged("EditDate");
          }
      }
  </code></pre>
  
  <p>Now the code works as expected, but of course every time I re-generate the proxy, my modifications are lost. I could change the calling code to the following:</p>
  
  <pre><code>DataContractBase myDataContract = new DataContractBase();
  myDataContract.EditDate = DateTime.Now;
  myDataContract.EditDateSpecified = true;
  
  new MyServiceClient.Update(new UpdateRequest(myDataContract));
  </code></pre>
  
  <p>but that also seems like a hack-ish waste of time.</p>
  
  <p>So finally, my question: does anyone have a suggestion on how to get past this unintuitive (and IMO broken) behavior of the Visual Studio service proxy generator, or am I simply missing something?</p>