在服务器端使用odata4j在客户端上使用breeze.js(master branch)和angular,如果我想查询国家/地区,我收到以下错误:
var query = breeze.EntityQuery.from('Country');
entityManager.executeQuery(query).then(...).fail(...);
-> Unable to locate a 'Type' by the name: Country:#odataContainer
我按照以下方式配置了微风:
breeze.config.initializeAdapterInstances({dataService: "OData"});
breeze.NamingConvention.none.setAsDefault();
... / $元数据OData响应:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="2.0" xmlns:m="...">
<Schema Namespace="odataContainer" xmlns="...">
<EntityContainer Name="odataEntities" m:IsDefaultEntityContainer="true">
<EntitySet Name="Country" EntityType="odataModel.Country">
</EntitySet>
</EntityContainer>
</Schema>
<Schema Namespace="odataModel" xmlns="...">
<EntityType Name="Country">
<Key>
<PropertyRef Name="countryCode"></PropertyRef>
</Key>
<Property Name="region" Type="Edm.String" Nullable="true"></Property>
<Property Name="population" Type="Edm.Int32" Nullable="false"></Property>
<Property Name="countryCode" Type="Edm.String" Nullable="false"></Property>
<Property Name="name" Type="Edm.String" Nullable="true"></Property>
</EntityType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
答案 0 :(得分:0)
您需要在项目中包含模型的命名空间。如果您的Country
课程位于odataModel.Country
,则需要添加第三行来配置oData
服务:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Department>("Countries");
builder.Namespace = "odataModel.Country";