Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove null DataMember properties from the response in wcf

I am returning the xml output to the browser with a wcf webservice, if a property of a DataContract is null, it still comes through in the response as

<Id i:nil="true" />

Is there a way to have it not return in the response at all?

like image 642
Nick Allen Avatar asked Jan 22 '10 16:01

Nick Allen


1 Answers

Figured it out myself, I needed to add the following atrribute to my DataMembers

[DataMember(EmitDefaultValue = false)]
like image 74
Nick Allen Avatar answered Oct 17 '22 02:10

Nick Allen