WCF Data Services: Avoiding __metadata Members

I'm currently experimenting using WCF data services as a way to open our product a bit more, while still being able to consume data from AJAX. One thing I noticed is that the JSON view format contains these __metada members sprinkled with data, and I found this in the OData documentation (under View Records ):

The optional name / value of the "__metadata" pair is the only pair that must be included on an object that does not directly represent the property Presented entry. This name / value pair is not data, but instead, by convention defined in this document, defines the metadata for the submitted record.

My question is: if this metadata is optional, how do I disable it in order to conserve bandwidth?

+5
source share
2 answers

You are correct that the WCF data services server implementation does not have the ability to not send __metadata. The fact that the protocol makes this optional does not mean that a particular implementation will not always send it. In this case, the server generates __metadata, because it may contain vital information for the client and without the payload may not make sense or provide incomplete information. Currently, the server also does not provide any way to change this behavior.

+2
source

Reflector, , , System.Data.Services.Serializers.JsonSerializer. , metada, WriteMetadataObject, WriteComplexTypeProperties WriteElementWithName - , .

, , JSON, $.

0

All Articles