在客户端使用breeze.js (主分支)和angular,在服务器端使用odata4j,如果我想查询国家/地区,我会收到以下错误:
var query = breeze.EntityQuery.from('Country');
entityManager.executeQuery(query).then(...).fail(...);
-> Unable to locate a 'Type' by the name: Country:#odataContainer 我已经对breeze进行了如下配置:
breeze.config.initializeAdapterInstances({dataService: "OData"});
breeze.NamingConvention.none.setAsDefault();.../$metadata 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>发布于 2013-04-19 01:30:05
您需要在项目中包含模型的命名空间。如果您的Country类在odataModel.Country中,则需要添加第三行来配置oData服务:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Department>("Countries");
builder.Namespace = "odataModel.Country"; https://stackoverflow.com/questions/15617957
复制相似问题