title: WCF IsRequired Attribute dilemma
body: <p>For a customer we are developing some WCF webservices. Our message contracts are defined by using  DataContract and DataMember attributes on top of our classes and their properties.
  The DataMember attribute has some extra properties that allows us to add some extra rules. For example if a property should always be available, we use (IsRequired=true); to indicate this. These rules are checked when a message is received or send.</p>
  
  <pre><code>[DataContract]
  public class TestClass      
  {  
      [DataMember(IsRequired = true)]  
      public int RequiredValue { get; set; }      
  }
  </code></pre>
  
  <p>However during our test we noticed that it doesn’t work, because at client side the RequiredValueField is initialized by null, so with some reading i found this property, EmitDefaultValue=false, so by using both, i get the desired result</p>
  
  <pre><code>[DataContract]  
  public class TestClass  
  {  
          [DataMember(IsRequired = true, EmitDefaultValue=false)]  
          public int RequiredValue { get; set; }  
  } 
  </code></pre>
  
  <p>but suppose, if some client initialize <code>RequiredValue = 0</code> and then call service method, it gives error again. <strong>So how do free my APIusers with an option that they can pass any thing in this member including zero, but when they omit then only it should give error</strong> ?</p>