简体   繁体   English

OData返回单节点

[英]OData return single node

i have a OData URI where i'm using $expand and $select. 我有一个OData URI,其中我正在使用$ expand和$ select。

http://odataservice.com/TripBookingPrices()?$expand=Trip&$select=TripId,Trip/ItemCode

It is working but in the results "Trip" is returning as a collection: 它正在工作,但是结果“ Trip”作为集合返回:

{"d": {"results": [
  {
  "__metadata":       {
     "uri": "http://odataservice.com/TripBookingPrices(229)",
     "type": "CodeFirstNamespace.TripBookingPrice"
  },
  "TripId": 46,
  "Trip":       {
     "__metadata":          {
        "uri": "http://odataservice.com/Trips(46)",
        "type": "CodeFirstNamespace.Trip"
     },
     "ItemCode": "ItemCode1"
  }

} }

It's there a way I can force it to return like this?: 有没有办法我可以强迫它像这样返回?:

{"d": {"results": [
  {
  "__metadata":       {
     "uri": "http://odataservice.com/TripBookingPrices(229)",
     "type": "CodeFirstNamespace.TripBookingPrice"
  },
  "TripId": 46,
  "ItemCode": "ItemCode1"

} }

no, there is no way to do that from query. 不,无法从查询中执行此操作。 But since it is your self-defined function(service operation), you can actually customize the return. 但是由于它是您自定义的函数(服务操作),因此您实际上可以自定义返回值。

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

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