WCF数据服务:如何避免__metadata成员 [英] WCF Data Services: How to avoid the __metadata members

查看:53
本文介绍了WCF数据服务:如何避免__metadata成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用WCF数据服务来更多地打开我们的产品,同时又能够使用来自AJAX的数据.我注意到的一件事是JSON表示格式将这些__metada成员散布在数据中,在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?

推荐答案

您是对的,因为WCF数据服务服务器实现不具有不发送__metadata的能力.该协议使其成为可选的事实并不意味着特定的实现不会总是发送该协议.在这种情况下,服务器会生成__metadata,因为它可能包含客户端的重要信息,而没有有效负载可能就没有意义或提供的信息不完整. 当前,服务器还没有提供任何选项来更改此行为.

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.

这篇关于WCF数据服务:如何避免__metadata成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆