Last post Feb 10, 2012 02:33 PM by kushalrdalal
Feb 10, 2012 01:25 PM|vmhatup|LINK
My class has several datamembers, but let's say a few of them end up being null or empty.
How can I set those particular members to [IgnoreDataMember] so that they're not exposed in the result?
Feb 10, 2012 01:45 PM|kushalrdalal|LINK
You do not have to make it ignore in order to not expose.
You can expose it and the client will not pass anything.
You have to make sure that once it is returned by client before processing you check for null and do the needful.
Feb 10, 2012 01:48 PM|vmhatup|LINK
Thanks for your reply.
I cannot even display the xml tag. The member must not be displayed in the XML if the member is null or empty.
Feb 10, 2012 02:28 PM|vmhatup|LINK
[DataMember(EmitDefaultValue = false)]
Feb 10, 2012 02:33 PM|kushalrdalal|LINK
As per microsoft they are not recommedning to use emitdefaultvalue= false.
Check this links -