Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Data Services: How to avoid the __metadata members

Tags:

wcf

odata

I'm currently experimenting with using WCF Data Services as a way to open up our product a bit more while at the same time being able to consume the data from AJAX. One thing that I noticed is that the JSON represention format has these __metada members sprinkled across the data, and in the OData documentation I found this (under Representing Entries):

An optional "__metadata" name/value pair is the only pair that should be included on the object that does not directly represent a Property of the Entry being represented. This name/value pair is not data, but instead, by convention defined in this document, specifies the metadata for the Entry being represented.

My question is, if this metadata is optional, how do I turn it off to save bandwidth?

like image 938
Dave Van den Eynde Avatar asked Nov 05 '22 09:11

Dave Van den Eynde


1 Answers

You are right that the WCF Data Services server implementation does not have the ability to not send the __metadata. The fact that the protocol makes it optional doesn't mean that a specific implementation won't send it always. In this case the server generates the __metadata because it may contain vital information for the client and without the the payload might not make sense or provide incomplete information. Currently the server also doesn't provide any option to change this behavior.

like image 128
Vitek Karas MSFT Avatar answered Nov 15 '22 05:11

Vitek Karas MSFT