title: Model binding of nested properties in asp.net core 2.2
body: <p>I'm trying to create a common complex object for my models (action parameters) and reuse it in many places.</p>
  
  <p>Here is some sample code:</p>
  
  <pre><code>[HttpGet("/api/values")]
  public ActionResult&lt;string&gt; Get([FromQuery] MyModel model) {
      var sb = new StringBuilder();
      sb.AppendLine(model.Id);
      sb.AppendLine($"{model.Id}-{model.Generated?.DateStart}-{model.Generated?.DateEnd}");
      sb.AppendLine($"{model.Id}-{model.Reference?.DateStart}-{model.Reference?.DateEnd}");
      return sb.ToString();
  }
  
  
  public class MyModel {
      public string Id { get; set; }
      public DateInfo Generated { get; set; } = new DateInfo();
      public DateInfo Reference { get; set; } = new DateInfo();
  }
  
  public class DateInfo {
      public DateTime? DateStart { get; set; }
      public DateTime? DateEnd { get; set; }
      public RelativeTime? RelativeTime { get; set; }
  }
  </code></pre>
  
  <p>Imagine the DateInfo class would have validation and common properties to be used in many models.</p>
  
  <p>Adding <code>[FromQuery(Name = "Something")]</code> to the nested properties does the trick for swagger, but it makes it impossible to have two nested properties with the same type.</p>
  
  <h2>UDPATE:</h2>
  
  <p>I understand that adding the fully qualified property name (<em>.../values?Id=1&amp;Generated.DateInfo=2&amp;Reference.DateInfo=3</em>) would make it work, but that would be a really ugly way to call any API. Hyphens are the way, not dots. </p>
  
  <p>I would like to map the binding in the same way as mapping a regular property.</p>
  
  <p>How to achieve that?</p>