2013-03-25 32 views
0

使用breeze.js(主分支)和角度对客户端与服务器端odata4j,我收到以下错误,如果我想查询国家:breezejs与OData的错误(odata4j)

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

您需要包括正你的模型在你的项目中。如果Country类别为odataModel.Country,则需要添加第三行以配置oData服务:

ODataModelBuilder builder = new ODataConventionModelBuilder(); 
builder.EntitySet<Department>("Countries"); 
builder.Namespace = "odataModel.Country";