【发布时间】:2020-02-19 19:34:53
【问题描述】:
我大致关注这个来自 apache olingo 页面的Tutorial。我想读取具有复杂属性的实体集合。
设置提供程序,访问http://localhost:8080/api/odata/$metadata时得到以下输出:
<?xml version="1.0" encoding="UTF-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="My.Namespace">
<EntityType Name="MyEntity">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.String"></Property>
<Property Name="name" Type="Edm.String"></Property>
<Property Name="description" Type="Edm.String"></Property>
<Property Name="complexProp" Type="My.Namespace.MyComplexType"></Property>
</EntityType>
<ComplexType Name="MyComplexType">
<Property Name="id" Type="Edm.String"></Property>
<Property Name="name" Type="Edm.String"></Property>
</ComplexType>
<EntityContainer Name="Container">
<EntitySet Name="MyEntities" EntityType="My.Namespace.MyEntity"></EntitySet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
这对我来说似乎没问题(是吗?)。但是我尝试读取访问http://localhost:8080/api/odata/MyEntities 的实体集合,我收到了返回消息
Cannot find type with name: My.Namespace.MyComplexType
当在序列化程序上调用 entityCollection 时,单步执行代码会显示处理器的 readEntityCollection 方法中抛出的期望。
我必须错过重要的一点,因为在我看来My.Namespace.MyComplexType 的定义很明确。
【问题讨论】:
-
如果您认为
$metadata输出有效,请发表评论。