简体   繁体   English

.net odata.metadata未显示成员类型

[英].net odata.metadata not showing for a member type

I have a type with a member that is not a simple type. 我有一个成员不是简单类型的类型。 For example, 例如,

class Person
{
   int a;
   Pmetadata personInfo;
}

Type Person is being returned as a response in an ODataController (WebAPI Framework). ODataController (WebAPI Framework)中,将类型Person作为响应返回。 In the response json returned from the controller, the root object has an 'odata.metadata' decoration, but the object personInfo doesn't have the 'odata.metadata' decoration. 在从控制器返回的响应json中,根对象具有'odata.metadata'装饰,但是对象personInfo没有'odata.metadata'装饰。 I tried adding type Pmetadata to the EntityModel using a call as follows, 我尝试使用如下调用将Pmetadata类型添加到EntityModel中,

odatamodelbuilder.EntitySet<Pmetadata>("PersonMetadata");

but it hasn't helped. 但这没有帮助。

What causes the odata.metadata to appear? 是什么导致odata.metadata出现?

Add $format to your request URL may resolve your problem: 在请求网址中添加$ format可能会解决您的问题:

GET ~/Products?$format=application/json;odata=fullmetadata

There is diff between these two requests, please have a try: 这两个请求之间存在差异,请尝试:

  1. http://services.odata.org/v3/OData/OData.svc/Products ?$format=application/json;odata=nometadata http://services.odata.org/v3/OData/OData.svc/Products?$ format = application / json; odata = nometadata
  2. http://services.odata.org/v3/OData/OData.svc/Products ?$format=application/json;odata=fullmetadata http://services.odata.org/v3/OData/OData.svc/Products?$ format = application / json; odata = fullmetadata

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM