I have a WCF service that allows external application to update my database. I have an Update Operation Contract that accepts a Data Contract that the external application should set. My problem is that I cannot distinguish what was set to null and what was not actually set because when the data contract is serialized the value is always null. Consider the following data contract:
[DataContract, XmlRoot("Person")]
public class Person: BaseEntity
{
[DataMember, XmlElement]
public string Prefix { get; set; }
[DataMember, XmlElement]
public string FirstName { get; set; }
[DataMember, XmlElement]
public string MiddleName { get; set; }
[DataMember, XmlElement]
public string LastName { get; set; }
[DataMember, XmlElement]
public string MaidenName { get; set; }
[DataMember, XmlElement]
}
One external application can only set the FirstName and the LastName and ignore the rest of the properties. But when my WCF service receive the request, the other properties are set to null. So my update statememt in my WCF service would think those properties where set to null. I wish to find a way to determine the properties were not set so that my update statement could ignore those properties.