title: ASP.NET MVC UpdateModel empty property
body: <p>Given the following Model,</p>
  
  <pre><code>public class A
  {
      public string Name { get; set; }
  }
  
  public class B
  {
      public string Address { get; set; }
      public A InstanceOfA { get; set; }
  }
  </code></pre>
  
  <p>View,</p>
  
  <pre><code>&lt;%= Html.TextBox("A.Name") %&gt;
  </code></pre>
  
  <p>and Controller</p>
  
  <pre><code>UpdateModel&lt;B&gt;(b, collection.ToValueProvider());
  </code></pre>
  
  <p>my b instance will contain a property of A with an empty string for Name.</p>
  
  <p>Is there anyway to have UpdateModel set the A property to null if no value has been entered for name?</p>
  
  <p>To clarify, this is a simple case, my real world scenario contains data models with hundreds of properties of this ilk. The definition of these data models is out of my hands. Therefore I need a solution for the general case, ie don't create a property if no values have been entered.</p>
  
  <p>Further clarification: i need this to work in edit scenarios aswell, i.e. an instance of b with A.Name set to "foo" is edited to set A.Name to "", i want A to be null.</p>