Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-340

How to retrieve both the entity references as well as the count of a collection referenced by a navigation property?

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_WD01
    • Fix Version/s: V4.0_WD01
    • Component/s: Protocol
    • Labels:
      None
    • Environment:

      [Applied]

      Description

      Currently if we want to retrieve the references to the individual entities instead of inlining the entities themselves the $expand syntax allows us to append /$ref to the navigation property that represents that collection of entities. If we wanted the size of that collection, after optionally applying any filters that might have been specified for such collection, one would need to add the $inlinecount ($count if ODATA-339 gets accepted) to be included as one of the expand options. This leads to the question how one could get both the count as well as the references to the individual entities as well as, come to think about it, how one could specify the order in which these references ought to be returned.

      In ODATA-339 the proposal is to allow /$count to be appended to a property in the select clause if one wanted to retrieve just the count. I was wondering if $ref should be moved to the select clause as well where $ref became just one of those special properties allowed to be used as appended to a navigation property or in a select nested within an expand were $ref would just be this 'special' property that would result in the reference to be injected in the projection and were it might optionally be combined with other properties (if that made sense)???

      I.e. these would then all be valid:

      http://host/service.svr/Customers?$select=Orders/$ref
      http://host/service.svr/Customers?$select=Orders/$count
      http://host/service.svr/Customers?$select=Orders/($select=$ref)
      http://host/service.svr/Customers?$select=Orders/($count,$select=$ref,$filter=Amount gt 100)
      http://host/service.svr/Customers?$select=Orders/($select=$ref,$orderby=OrderID)

        Attachments

          Activity

          Hide
          ralfhandl Ralf Handl added a comment -

          We could use

          Customers?$expand=Orders/$ref($inlinecount=allpages)

          or whatever ODATA-323 results in for $inlinecount

          Show
          ralfhandl Ralf Handl added a comment - We could use Customers?$expand=Orders/$ref($inlinecount=allpages) or whatever ODATA-323 results in for $inlinecount
          Hide
          hubert.heijkers Hubert Heijkers (Inactive) added a comment -

          That implies we can 'expand' references? That feels very unnatural to me. Do we even allow this currently?

          Show
          hubert.heijkers Hubert Heijkers (Inactive) added a comment - That implies we can 'expand' references? That feels very unnatural to me. Do we even allow this currently?
          Hide
          ralfhandl Ralf Handl added a comment -

          Yes, we added it with ODATA-276:

          Customers?$expand=Orders/$ref <=get customers and the refs for their orders
          Customers?$expand=Orders($filter=Amount>100)/$ref <=get customers and the ref for orders over $100

          So we can already do

          Customers?$expand=Orders($inlinecount=allpages)/$ref

          and receive inlined feeds of entity references which also contain an odata.count annotation or <metadata:count> element, depending on the format.

          The syntax above might change due to ODATA-323 and ODATA-345.

          So I propose to close this ticket without action.

          Show
          ralfhandl Ralf Handl added a comment - Yes, we added it with ODATA-276 : Customers?$expand=Orders/$ref <=get customers and the refs for their orders Customers?$expand=Orders($filter=Amount>100)/$ref <=get customers and the ref for orders over $100 So we can already do Customers?$expand=Orders($inlinecount=allpages)/$ref and receive inlined feeds of entity references which also contain an odata.count annotation or <metadata:count> element, depending on the format. The syntax above might change due to ODATA-323 and ODATA-345 . So I propose to close this ticket without action.
          Hide
          sdrees Stefan Drees (Inactive) added a comment -

          Ass discussed in meeting #34

          Show
          sdrees Stefan Drees (Inactive) added a comment - Ass discussed in meeting #34

            People

            • Assignee:
              handl Ralf Handl
              Reporter:
              hubert.heijkers Hubert Heijkers (Inactive)
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: