Hi
I'm using XML Serialization for serializing an object. I read aset of records from the database and populate the members of theobject if the value is not null. eg., I have an Employee objectwhich has its members Id,name and address. If the Id is not nullthen I will populate its value from that I got from the databse.When I serialize the object , I find that xml structure willalways have the Id column either with the actual value or withvalue 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 fordata types int, boolean and date and will have a value0,0001-01-01 and false as default values respectively.
I cannot set the property <XmlElement(IsNullable:=True)> forvalue types. Is there any way where I can avoid serializingtypes of int,date and boolean when they have null values in thedatabase.
Regards
RJN
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>kXtPhKBi506Nm6J+4QneYg==</Id>