Yesterday I came across a problem. I was asked to write a rest service which exposes all properties of a class. The consumers would all consume different properties and when submitting they would all send different subsets of them. For example sake lets call the contract company.
class Company{
public string Address {get;set;}
public string CompanyNumber {get;set;}
public string Turnover {get;set;}
public string Employees {get;set;}
}
Lets say we have two known systems which would like to sync the Company class. System 1 deals with accounting and wants to read Address and Update Turnover. System 2 deals with hr and wants to read Address and update Employees. Now normally when faced with this problem one would write lots of interfaces each with a tailored contract to suit the end system. However I have been told this is not what they want. Instead if the property is supplied in the JSON it must be set.
The problem is when deserialising the class Company from JSON if the property is not supplied the property is null, this will then when mapped to the database classes overwrite the data.