title: Deserialize enums using the EnumMember value in AspNet [FromQuery] model binding
body: <p>I have an endpoint in .NET 6 <code>Microsoft.NET.Sdk.Web</code> project that deserialize query strings into a .NET object by using the standard [FromQuery]</p>
  <pre><code>[Route(&quot;[controller]&quot;)]
  public class SamplesController
      : ControllerBase
  {
      [HttpGet]
      public IActionResult Get([FromQuery]QueryModel queryModel)
      {
          if (!queryModel.Status.HasValue)
          {
              return BadRequest(&quot;Problem in deserialization&quot;);
          }
          
          return Ok(queryModel.Status.Value.GetEnumDisplayName());
      }
  }
  </code></pre>
  <p>The model contains an enum</p>
  <pre><code>public class QueryModel
  {
      /// &lt;summary&gt;
      /// The foo parameter
      /// &lt;/summary&gt;
      /// &lt;example&gt;bar&lt;/example&gt;
      public string? Foo { get; init; } = null;
      
      /// &lt;summary&gt;
      /// The status
      /// &lt;/summary&gt;
      /// &lt;example&gt;on-hold&lt;/example&gt;
      public Status? Status { get; set; } = null;
  }
  </code></pre>
  <p>And the enum has <code>EnumMember</code> attributes which value I want to use to deserialize from.</p>
  <pre><code>public enum Status
  {
      [EnumMember(Value = &quot;open&quot;)]
      Open,
      
      [EnumMember(Value = &quot;on-hold&quot;)]
      OnHold
  }
  </code></pre>
  <p>By default, .NET 6 does not take into consideration the <code>EnumMember</code> when deserializing.</p>
  <p>The goal is to be able to send requests such as</p>
  <pre><code>http://localhost:5000/Samples?Foo=bar&amp;Status=on-hold 
  </code></pre>
  <p>and have the controller's action deserialize the <code>QueryModel</code> with the proper <code>Status.OnHold</code> value by using its <code>EnumMember</code></p>
  <p>I have tried without luck an extensions library that contains a converter, but the converter is not getting triggered when using <code>[FromQuery]</code>. See <a href="https://github.com/Macross-Software/core/issues/30" rel="nofollow noreferrer">https://github.com/Macross-Software/core/issues/30</a></p>
  <p>I have added a project to reproduce problem and as a sandbox to provide a solution**
  <a href="https://gitlab.com/sunnyatticsoftware/issues/string-to-enum-mvc/-/tree/feature/1-original-problem" rel="nofollow noreferrer">https://gitlab.com/sunnyatticsoftware/issues/string-to-enum-mvc/-/tree/feature/1-original-problem</a></p>
  <p>NOTE: I would need a solution where the Enum and the does not require any external dependency (just .NET sdk).</p>