我正在尝试与 OData 服务器(基于 XPO)进行交流。在来自服务器导航属性的元数据 xml 中存在,但它们不是为客户端类型的元数据创建的。我做错了什么还是有错误?
服务器元数据 xml:
http://odataserver/Db.svc/$metadata
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="Namespace">
<EntityType Name="Question">
<Key>
<PropertyRef Name="Oid"/>
</Key>
<Property Name="Oid" Type="Edm.Int32" Nullable="false"/>
<Property Name="No" Type="Edm.String"/>
<Property Name="Header" Type="Edm.String"/>
<NavigationProperty Name="Chapter" Relationship="Namespace.Question_Chapter_Chapter_Questions" ToRole="Chapter_Questions" FromRole="Question_Chapter"/>
</EntityType>
<EntityType Name="Chapter">
<Key>
<PropertyRef Name="Oid"/>
</Key>
<Property Name="Oid" Type="Edm.Int32" Nullable="false"/>
<Property Name="No" Type="Edm.String"/>
<Property Name="Name" Type="Edm.String"/>
<NavigationProperty Name="Questions" Relationship="Namespace.Question_Chapter_Chapter_Questions" ToRole="Question_Chapter" FromRole="Chapter_Questions"/>
</EntityType>
<Association Name="Question_Chapter_Chapter_Questions">
<End Type="Namespace.Chapter" Role="Chapter_Questions" Multiplicity="0..1"/>
<End Type="Namespace.Question" Role="Question_Chapter" Multiplicity="*"/>
</Association>
<EntityContainer Name="DbService" m:IsDefaultEntityContainer="true">
<EntitySet Name="Question" EntityType="Namespace.Question"/>
<EntitySet Name="Chapter" EntityType="Namespace.Chapter"/>
<AssociationSet Name="Question_Chapter_Chapter" Association="Namespace.Question_Chapter_Chapter_Questions">
<End Role="Question_Chapter" EntitySet="Question"/>
<End Role="Chapter_Questions" EntitySet="Chapter"/>
</AssociationSet>
</EntityContainer>
<Annotations Target="Namespace.Chapter/No">
<ValueAnnotation Term="Org.OData.Validation.V1.Size" Int="100"/>
</Annotations>
<Annotations Target="Namespace.Chapter/Name">
<ValueAnnotation Term="Org.OData.Validation.V1.Size" Int="100"/>
</Annotations>
<Annotations Target="Namespace.Question/No">
<ValueAnnotation Term="Org.OData.Validation.V1.Size" Int="100"/>
</Annotations>
<Annotations Target="Namespace.Question/Header">
<ValueAnnotation Term="Org.OData.Validation.V1.Size" Int="100"/>
</Annotations>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
问题有一个导航属性:
<NavigationProperty Name="Chapter" Relationship="Namespace.Question_Chapter_Chapter_Questions" ToRole="Chapter_Questions" FromRole="Question_Chapter"/>
但是当我发出命令时:
manager.metadataStore.getEntityType("Question")
将元数据加载到微风后,结果在 navigationProperties 数组中有 0 项。