WCF 数据服务 : How to avoid the __metadata members

标签 wcf odata

我目前正在尝试使用 WCF 数据服务作为一种方式来更多地打开我们的产品,同时能够使用来自 AJAX 的数据。我注意到的一件事是 JSON 表示格式有这些 __metada 成员散布在数据中,在 OData 文档中我发现了这个(在 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.



我的问题是,如果此元数据是可选的,我该如何关闭它以节省带宽?

最佳答案

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

关于WCF 数据服务 : How to avoid the __metadata members,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3492706/

相关文章:

rest - 如何通过 Azure 移动服务使用服务器端排序和分页

angularjs - 是否有任何 AngularJS + ASP.NET-WebApi + OData + Breeze.js + Typescript 示例或是否有人尝试将它们结合起来

c# - StructureMap(或任何 IoC)和 WCF

c# - WCF ServiceActivationException 混淆

wcf - 如何在发送到通过 MQ 激活的 WF 服务的 MSMQ 消息的客户端设置优先级

wcf - 为什么我需要 mex 端点和 httpGetEnable?

javascript - OData $top 和 PageSize 对 Web API 性能没有影响

c# - 使用简单 TCP 时如何启用 WCF 压缩?

odata - 为什么我的 OData 返回数据包含 "@odata.type"?

c# - 如何在 C# 中解析 OData $filter