2013-03-25 54 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";