对空 OData 导航的 GET 请求的正确响应是什么 属性
What is the correct response for a GET request to anempty OData Navigation property
比如说,对于下面定义的这样一个实体,GET“serviceRoot/entity(1)/nav”的正确响应是什么?假设 ID 为 1 的实体具有有效值,但其存储的 'nav' 引用键为空。
<EntityType Name="entityType">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Nullable="false" Type="Edm.Integer"/>
<Property Name="name" Nullable="false" Type="Edm.String"/>
<NavigationProperty Name="nav" Nullable="true" Type="this.navType"/>
</EntityType>
<EntityType Name="navType">
<Key>
<PropertyRef Name="navId"/>
</Key>
<Property Name="navId" Nullable="false" Type="Edm.Integer"/>
<Property Name="name" Nullable="false" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="Container">
<EntitySet EntityType="navType" Name="navSet"/>
<EntitySet EntityType="entityType" Name="entity">
<NavigationPropertyBinding Path="nav" Target="this.navSet"/>
</EntitySet>
</EntityContainer>
204 No Content 是根据 OData v4 规范的正确响应。
If the relationship terminates on a single entity, the response MUST be the format-specific representation of the related single entity. If no entity is related, the service returns 204 No Content.
来源:Requesting Related Entities
猜对了!
比如说,对于下面定义的这样一个实体,GET“serviceRoot/entity(1)/nav”的正确响应是什么?假设 ID 为 1 的实体具有有效值,但其存储的 'nav' 引用键为空。
<EntityType Name="entityType">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Nullable="false" Type="Edm.Integer"/>
<Property Name="name" Nullable="false" Type="Edm.String"/>
<NavigationProperty Name="nav" Nullable="true" Type="this.navType"/>
</EntityType>
<EntityType Name="navType">
<Key>
<PropertyRef Name="navId"/>
</Key>
<Property Name="navId" Nullable="false" Type="Edm.Integer"/>
<Property Name="name" Nullable="false" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="Container">
<EntitySet EntityType="navType" Name="navSet"/>
<EntitySet EntityType="entityType" Name="entity">
<NavigationPropertyBinding Path="nav" Target="this.navSet"/>
</EntitySet>
</EntityContainer>
204 No Content 是根据 OData v4 规范的正确响应。
If the relationship terminates on a single entity, the response MUST be the format-specific representation of the related single entity. If no entity is related, the service returns 204 No Content.
来源:Requesting Related Entities
猜对了!