2

I was wondering how to use the PATCH HTTP verb on my application since sometimes I don't need to update the whole entity.

The problem, is that in C# the lack of value is represented by null (there is not undefined like in JS).

So considering that I have this entity in my DB:

public class Dog
{
   public Int32 Id {get;set;}
   public String Name {get;set;}
   public String FamilyName {get;set;}
   public Int32 Age {get;set;}
}

And I use this entity to represent the data exchange in my endpoint:

public class DogInModel
{
   public Int32 Id {get;set;}
   public String Name {get;set;}
   public String FamilyName {get;set;}
   public Int32? Age {get;set;}
}

How do I PATCH an existing entity to set FamilyName to null, by only sending the Id and the FamilyName, without setting the Name field no null in the process?

In other words, how can I design a model that informs me of the properties that the client is actually sending?

Cheers.

vtortola
  • 34,709
  • 29
  • 161
  • 263
  • I feel like this may be a duplicate of http://stackoverflow.com/questions/14177676/whats-the-currently-recommended-way-of-performing-partial-updates-with-web-api/14219403#14219403 – Mark Jones Jul 17 '13 at 08:24

0 Answers0