OData expand functionality question RRS feed

  • Question

  • User990771509 posted

    Currently building a web service for work and I need some advice/help.
    The two related entities are Sites and Site Records (Site records being a entity collection inside of Site). 

    There is a Boolean property in Site Record called IsPublic which acts as a flag for when the record has undergone review and been approved for public consumption. 
    I currently have all of the routes working off of this logic 

    Sites/  - A list of all sites that have publicly available records

    Sites(id)/SiteRecords - the list of all publicly available records for a site. 

    The problem is that if you do an expand on Sites/?expand=SiteRecords   it will return to you the list of all Site Records regardless of flag set. Does anyone have any suggestions on how to best handle this?

    Thanks in advance for any help offered,

    ~Justin .

    Saturday, March 25, 2017 7:06 PM

All replies

  • User-2057865890 posted

    Hi Justin,

    $expand Expands related entities inline.

    Query options can be applied to the expanded navigation property by appending a semicolon-separated list of query options, enclosed in parentheses, to the navigation property name. Allowed system query options are $filter, $select, $orderby, $skip, $top, $count, $search, and $expand.

    Example 93: all categories and for each category all related products with a discontinued date equal to null

                                $expand=Products($filter=DiscontinuedDate eq null)

    reference: http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html

    Best Regards,


    Tuesday, March 28, 2017 3:01 AM