XML Serialization
Hi
I'm using XML Serialization for serializing an object. I read a set of records from the database and populate the members of the object if the value is not null. eg., I have an Employee object which has its members Id,name and address. If the Id is not null then I will populate its value from that I got from the databse. When I serialize the object , I find that xml structure will always have the Id column either with the actual value or with value 0 if the value is Null in the databse.
<employees>
<employee><Id>111</Id><name>aaa</name></employee>
<employee><Id>0</Id></name></employee>
</employees>
My feeling is this is the default behaviour of xml serializer for data types int, boolean and date and will have a value 0,0001-01-01 and false as default values respectively.
I cannot set the property <XmlElement(IsNullable:=True)> for value types. Is there any way where I can avoid serializing types of int,date and boolean when they have null values in the database.
Regards
RJN
|