src/POData/Providers/Metadata/SimpleMetadataProvider.php
/**
     * To add a navigation property (resource set or resource reference)
     * to a resource type
     * 
     * @param ResourceType         $resourceType         The resource type to add 
     *                                                   the resource reference 
     *                                                   or resource 
     *                                                   reference set property to
     * @param string               $name                 The name of the 
     *                                                   property to add
     * @param ResourceSet          $targetResourceSet    The resource set the 
     *                                                   resource reference
     *                                                   or reference 
     *                                                   set property 
     *                                                   ponits to
     * @param ResourcePropertyKind $resourcePropertyKind The property kind
     * 
     * @return void
     */
To add a navigation property (resource set or resource reference)
to a resource type

@param ResourceType         $resourceType         The resource type to add
the resource reference
or resource
reference set property to
@param string               $name                 The name of the
property to add
@param ResourceSet          $targetResourceSet    The resource set the
resource reference
or reference
set property
ponits to
@param ResourcePropertyKind $resourcePropertyKind The property kind

@return void
To add a navigation property ( resource set or resource reference ) to a resource type @param ResourceType $resourceType The resource type to add the resource reference or resource reference set property to @param string $name The name of the property to add @param ResourceSet $targetResourceSet The resource set the resource reference or reference set property ponits to @param ResourcePropertyKind $resourcePropertyKind The property kind @return void
private function _addReferencePropertyInternal(
	    ResourceType $resourceType,
	    $name,
        ResourceSet $targetResourceSet,
        $resourcePropertyKind
    ) {
        try {
            $resourceType->getInstanceType()->getProperty($name);
        } catch (\ReflectionException $exception) {
            throw new InvalidOperationException(
                'Can\'t add a property which does not exist on the instance type.'
            );
        }
        if (!($resourcePropertyKind == ResourcePropertyKind::RESOURCESET_REFERENCE 
            || $resourcePropertyKind == ResourcePropertyKind::RESOURCE_REFERENCE)
        ) {
            throw new InvalidOperationException(
                'Property kind should be ResourceSetReference or ResourceReference'
            );
        }
        $targetResourceType = $targetResourceSet->getResourceType();
        $resourceProperty = new ResourceProperty($name, null, $resourcePropertyKind, $targetResourceType);
        $resourceType->addProperty($resourceProperty);
        $sourceResourceSet = $resourceType->getCustomState();
        if (is_null($sourceResourceSet)) {
            throw new InvalidOperationException('Failed to retrieve the custom state from ' . $resourceType->getName());
        }
        $setKey = $resourceType->getName() . '_' .  $name . '_' . $targetResourceSet->getName();
        $set = new ResourceAssociationSet(
            $setKey,
            new ResourceAssociationSetEnd($sourceResourceSet, $resourceType, $resourceProperty),
            new ResourceAssociationSetEnd($targetResourceSet, $targetResourceSet->getResourceType(), null)
        );
        $this->associationSets[$setKey] = $set;
    }
private function _addReferencePropertyInternal ( ResourceType $ resourceType , $ name , ResourceSet $ targetResourceSet , $ resourcePropertyKind ) { try { $ resourceType -> getInstanceType ( ) -> getProperty ( $ name ) ; } catch ( \ ReflectionException $ exception ) { throw new InvalidOperationException ( 'Can\'t add a property which does not exist on the instance type.' ) ; } if ( ! ( $ resourcePropertyKind == ResourcePropertyKind :: RESOURCESET_REFERENCE || $ resourcePropertyKind == ResourcePropertyKind :: RESOURCE_REFERENCE ) ) { throw new InvalidOperationException ( 'Property kind should be ResourceSetReference or ResourceReference' ) ; } $ targetResourceType = $ targetResourceSet -> getResourceType ( ) ; $ resourceProperty = new ResourceProperty ( $ name , null , $ resourcePropertyKind , $ targetResourceType ) ; $ resourceType -> addProperty ( $ resourceProperty ) ; $ sourceResourceSet = $ resourceType -> getCustomState ( ) ; if ( is_null ( $ sourceResourceSet ) ) { throw new InvalidOperationException ( 'Failed to retrieve the custom state from ' . $ resourceType -> getName ( ) ) ; } $ setKey = $ resourceType -> getName ( ) . '_' . $ name . '_' . $ targetResourceSet -> getName ( ) ; $ set = new ResourceAssociationSet ( $ setKey , new ResourceAssociationSetEnd ( $ sourceResourceSet , $ resourceType , $ resourceProperty ) , new ResourceAssociationSetEnd ( $ targetResourceSet , $ targetResourceSet -> getResourceType ( ) , null ) ) ; $ this -> associationSets [ $ setKey ] = $ set ; }
To add a navigation property (resource set or resource reference)
 to a resource type
To add a navigation property ( resource set or resource reference ) to a resource type
//Create instance of AssociationSet for this relationship         //Customer_Orders_Orders, Order_Customer_Customers  //(source type::name _ source property::name _ target set::name)