title: Web API 2 - Implementing a PATCH
body: <p>I currently have a Web API that implements a RESTFul API. The model for my API looks like this:</p>
  <pre><code>public class Member
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public DateTime Created { get; set; }
      public DateTime BirthDate { get; set; }
      public bool IsDeleted { get; set; }
  }
  </code></pre>
  <p>I've implemented a <code>PUT</code> method for updating a row similar to this (for brevity, I've omitted some non-relevant stuff):</p>
  <pre><code>[Route(&quot;{id}&quot;)]
  [HttpPut]
  public async System.Threading.Tasks.Task&lt;HttpResponseMessage&gt; UpdateRow(int id, 
      [FromBody]Models.Member model)
  {
      // Do some error checking
      // ...
      // ...
  
      var myDatabaseEntity = new BusinessLayer.Member(id);
      myDatabaseEntity.FirstName = model.FirstName;
      myDatabaseEntity.LastName = model.LastName;
      myDatabaseEntity.Created = model.Created;
      myDatabaseEntity.BirthDate = model.BirthDate;
      myDatabaseEntity.IsDeleted = model.IsDeleted;
  
      await myDatabaseEntity.SaveAsync();
  }
  </code></pre>
  <p>Using <a href="https://www.getpostman.com/" rel="noreferrer">PostMan</a>, I can send the following JSON and everything works fine:</p>
  <pre><code>{
      firstName: &quot;Sara&quot;,
      lastName: &quot;Smith&quot;,
      created: &quot;2018/05/10&quot;,
      birthDate: &quot;1977/09/12&quot;,
      isDeleted: false
  }
  </code></pre>
  <p>If I send this as my body to <code>http://localhost:8311/api/v1/Member/12</code> as a PUT request, the record in my data with ID of 12 gets updated to what you see in the JSON.</p>
  <p>What I would like to do though is implement a PATCH verb where I can do partial updates. If Sara gets married, I would like to be able to send this JSON:</p>
  <pre><code>{
      lastName: &quot;Jones&quot;
  }
  </code></pre>
  <p>I would like to be able to send just that JSON and update JUST the <code>LastName</code> field and leave all the other fields alone.</p>
  <p>I tried this:</p>
  <pre><code>[Route(&quot;{id}&quot;)]
  [HttpPatch]
  public async System.Threading.Tasks.Task&lt;HttpResponseMessage&gt; UpdateRow(int id, 
      [FromBody]Models.Member model)
  {
  }
  </code></pre>
  <p>My problem is that this returns all the fields in the <code>model</code> object (all of them are nulls except the <code>LastName</code> field), which makes sense since I am saying I want a <code>Models.Member</code> object. What I would like to know is if there is a way to detect which properties have actually been sent in the JSON request so I can update just those fields?</p>