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.