简体   繁体   中英

OData return single node

i have a OData URI where i'm using $expand and $select.

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

It is working but in the results "Trip" is returning as a collection:

{"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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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