wcf data services - Suppress emitting of default values in WCF ODATA -
i have data entity poco set in self-hosted wcf odata service running wcf data services 5.5.
the data entity has several string properties null. i'd suppress output of these properties when null reduce size of data crosses wire.
[dataserviceentity] [dataservicekey("id")] public class mydata { public string id { get; set; } [system.runtime.serialization.datamember(emitdefaultvalue=false)] public string description { get; set; } }
datamember(emitdefaultvalue = false)
seems have no effect on data entity serialization:
{ "id":"test4", "description":null }
how can persuade wcf data services suppress null property?
do know asp.net web api odata provider? http://www.nuget.org/packages/microsoft.aspnet.webapi.odata
you can write own serializer. (inherit odatafeedserializer) odataentry class has key/value property called "properties". can try clear out empty properties there.
Comments
Post a Comment