public function writeTopLevelPrimitive(QueryResult & $primitiveValue, ResourceProperty & $resourceProperty = null)
    {
        if (null === $resourceProperty) {
            throw new InvalidOperationException('Resource property must not be null');
        }
        $propertyContent = new ODataPropertyContent();

        $odataProperty = new ODataProperty();
        $odataProperty->name = $resourceProperty->getName();
        $iType = $resourceProperty->getInstanceType();
        if (!$iType instanceof IType) {
            throw new InvalidOperationException(get_class($iType));
        }
        $odataProperty->typeName = $iType->getFullTypeName();
        if (null == $primitiveValue->results) {
            $odataProperty->value = null;
        } else {
            $rType = $resourceProperty->getResourceType()->getInstanceType();
            if (!$rType instanceof IType) {
                throw new InvalidOperationException(get_class($rType));
            }
            $odataProperty->value = $this->primitiveToString($rType, $primitiveValue->results);
        }

        $propertyContent->properties[$odataProperty->name] = $odataProperty;

        return $propertyContent;
    }