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

Specify navigation property binding combined with containment

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_OS
    • Fix Version/s: V4.01_CSD02
    • Component/s: CSDL XML
    • Labels:
    • Environment:

      Applied

    • Proposal:
      Hide

      Note: as per ODATA-1030, for annotating an entity or complex type, use a new membership constraint annotation in the validation vocabulary.

      1) Support NavigationPropertyBinding element as a child of EntityType, ComplexType or Singleton.

      2) When used in a NavigationPropertyBinding within an EntityType or ComplexType, "Path" is a path starting with a property or navigation property on the type containing the NavigationPropertyBinding element, traversing zero or more containment navigation properties, complex types, or collections of complex types, and terminating on a non-containment navigation property. If the path includes a collection of complex types or a collection-valued navigation property, then the binding applies to all members of that collection. Also support cast segments as in NavigationPropertyBinding Path today.

      3) Clarify in current use of NavigationPropertyBinding that Path may traverse collections of complex types, and that when traversing collections of complex types or collection-valued navigation properties, the binding applies to all members of that collection.

      4) Rules 2 & 3 mean that the Path attribute has the same syntax and semantics whether the NavigationPropertyBinding is under an EntitySet, Singleton, EntityType, or a ComplexType.

      5) When used in a NavigationPropertyBinding within an EntityType or ComplexType, "Target" is a path starting with a property or navigation property on the type containing the NavigationPropertyBinding element, traversing zero or more single-valued containment navigation properties or complex types, and terminating on a containment navigation property.

      6) Support cast segments in the Target attribute of NavigationPropertyBindings, both in current usage and when child of an Singleton or Entity/Complex type element declaration. Note that a cast segment both casts and filters, so you could have the same navigationpropertybinding for the same navigation property cast (in Path) to different types, meaning members of the collection that are one type come from one entity set while members of the collection that are a different type come from a different entity set.

      7) Clarify in current usage of NavigationPropertyBinding that Target may only traverse single-valued containment navigation properties or complex types.

      8) When used in a NavigationPropertyBinding within an EntitySet or Singleton, Target may identify an entity set, singleton, or containment navigation property, but when used within an EntityType or ComplexType it must terminate in a containment navigation property. This is by design and prevents type definitions from being tied to a container. All other semantics and syntax of Target are the same whether the NavigationPropertyBinding element is the child of an EntitySet, Singleton, EntityType, or ComplexType.

      9) The new usage is only allowed in a 4.01 schema:
      a. Can only have NavigationPropertyBinding as a child of Singleton, EntityType, or ComplexType in 4.01 responses
      b. Services should only use cast segments in Target attribute in 4.01 responses
      c. Services should only return navigation property bindings whose Path traverses collections of complex types in 4.01 responses

      Show
      Note: as per ODATA-1030 , for annotating an entity or complex type, use a new membership constraint annotation in the validation vocabulary. 1) Support NavigationPropertyBinding element as a child of EntityType, ComplexType or Singleton. 2) When used in a NavigationPropertyBinding within an EntityType or ComplexType, "Path" is a path starting with a property or navigation property on the type containing the NavigationPropertyBinding element, traversing zero or more containment navigation properties, complex types, or collections of complex types, and terminating on a non-containment navigation property. If the path includes a collection of complex types or a collection-valued navigation property, then the binding applies to all members of that collection. Also support cast segments as in NavigationPropertyBinding Path today. 3) Clarify in current use of NavigationPropertyBinding that Path may traverse collections of complex types, and that when traversing collections of complex types or collection-valued navigation properties, the binding applies to all members of that collection. 4) Rules 2 & 3 mean that the Path attribute has the same syntax and semantics whether the NavigationPropertyBinding is under an EntitySet, Singleton, EntityType, or a ComplexType. 5) When used in a NavigationPropertyBinding within an EntityType or ComplexType, "Target" is a path starting with a property or navigation property on the type containing the NavigationPropertyBinding element, traversing zero or more single-valued containment navigation properties or complex types, and terminating on a containment navigation property. 6) Support cast segments in the Target attribute of NavigationPropertyBindings, both in current usage and when child of an Singleton or Entity/Complex type element declaration. Note that a cast segment both casts and filters, so you could have the same navigationpropertybinding for the same navigation property cast (in Path) to different types, meaning members of the collection that are one type come from one entity set while members of the collection that are a different type come from a different entity set. 7) Clarify in current usage of NavigationPropertyBinding that Target may only traverse single-valued containment navigation properties or complex types. 8) When used in a NavigationPropertyBinding within an EntitySet or Singleton, Target may identify an entity set, singleton, or containment navigation property, but when used within an EntityType or ComplexType it must terminate in a containment navigation property. This is by design and prevents type definitions from being tied to a container. All other semantics and syntax of Target are the same whether the NavigationPropertyBinding element is the child of an EntitySet, Singleton, EntityType, or ComplexType. 9) The new usage is only allowed in a 4.01 schema: a. Can only have NavigationPropertyBinding as a child of Singleton, EntityType, or ComplexType in 4.01 responses b. Services should only use cast segments in Target attribute in 4.01 responses c. Services should only return navigation property bindings whose Path traverses collections of complex types in 4.01 responses
    • Resolution:
      Show
      https://www.oasis-open.org/committees/download.php/60253/odata-csdl-json-v4.01-wd01-2017-03-10.docx https://www.oasis-open.org/committees/download.php/60254/odata-csdl-xml-v4.01-wd02-2017-03-10.docx

      Description

      This combination is not explicitly covered in the specification.

      There are two sides to this problem:

      • target entity sets for contained entities
      • contained entity sets as target entity sets

      Both problems can be solved by allowing <NavigationPropertyBinding> elements as children of the structured type that defines the containment navigation property.

      Example 1: navigation property of a contained entity targets a top-level entity set:
      <NavigationProperty Name="Items" Type="Collection(Model.OrderItem)" ContainsTarget="true" />
      <NavigationPropertyBinding Path="Items/Product" Target="Model.Container/Products"/>

      Example 2: assume an Order contains Items and Shipments, and an Item refers to a single Shipment of the same Order and vice versa. Using paths that start at the type defining the containment navigation property, the Target would be "Shipments" and "Items".
      <EntityType Name="Order">
      <NavigationProperty Name="Items" Type="Collection(Model.OrderItem)" ContainsTarget="true" />
      <NavigationPropertyBinding Path="Items/Shipment" Target="Shipments"/>
      <NavigationProperty Name="Shipments" Type="Collection(Model.Shipment)" ContainsTarget="true" />
      <NavigationPropertyBinding Path="Shipments/ShippedItems" Target="Items"/>
      </EntityType>

      <EntityType Name="OrderItem">
      <NavigationProperty Name="Shipment" Type="Model.Shipment" Partner="ShippedItems"/>
      </EntityType>

      <EntityType Name="Shipment">
      <NavigationProperty Name="ShippedItems" Type="Collection(Model.OrderItem)" Partner="Shipment"/>
      </EntityType>

        Attachments

          Activity

            People

            • Assignee:
              mikep Michael Pizzo (Inactive)
              Reporter:
              handl Ralf Handl
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: