Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 10, 2012 01:33 PM by kushalrdalal
Feb 10, 2012 12:25 PM|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 12:45 PM|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 12:48 PM|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 01:28 PM|LINK
[DataMember(EmitDefaultValue = false)]
Feb 10, 2012 01:33 PM|LINK
As per microsoft they are not recommedning to use emitdefaultvalue= false.
Check this links -