0

Using breeze.js (master branch) and angular on client with odata4j on the server-side, I'm receiving the following error if i want to query for countries:

var query = breeze.EntityQuery.from('Country');
entityManager.executeQuery(query).then(...).fail(...);

-> Unable to locate a 'Type' by the name: Country:#odataContainer 

I've configured breeze as follows:

  breeze.config.initializeAdapterInstances({dataService: "OData"});
  breeze.NamingConvention.none.setAsDefault();

.../$metadata OData response:

<?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>
4

1 回答 1

0

您需要在项目中包含模型的命名空间。如果您的Country班级在odataModel.Country您需要添加第三行来配置oData服务:

ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Department>("Countries");
builder.Namespace = "odataModel.Country"; 
于 2013-04-18T17:30:04.933 回答