javascript - breezejs 导航刷新 "There is no resourceName for this query"

标签 javascript breeze

我有一个 breeze js 导航属性,所有加载都很好,但我想刷新导航记录,所以我尝试使用以下代码

this.data().entityAspect
  .loadNavigationProperty('PropertyDocuments')
  .fail((reason) => alert("Data refresh failed" + reason));

这给出了错误此查询没有资源名称

刷新这个的正确方法是什么?

导航属性数据:-

?this.data().getProperty('PropertyDocuments');
__proto__: []
_addsInProcess: []
arrayChanged: {...}
length: 19
navigationProperty: {...}
parentEntity: {...}
wasLoaded: true
[0]: {...}
[1]: {...}
[2]: {...}
[3]: {...}


?this.data().getProperty('PropertyDocuments').navigationProperty
__proto__: {...}
associationName: "PropertyDocument_PropertyForSale"
entityType: {...}
entityTypeName: "PropertyDocument:#DomainModel.Models"
foreignKeyNames: []
foreignKeyNamesOnServer: []
inverse: {...}
invForeignKeyNames: [PropertyID]
invForeignKeyNamesOnServer: [PropertyID]
isScalar: false
name: "PropertyDocuments"
nameOnServer: "PropertyDocuments"
parentType: {...}
validators: []

最佳答案

这可能是由于没有与导航属性返回的 entityType 关联的“默认”资源名称造成的。 breeze 使用 resourceName 来确定要调用的 Web 服务端点。

查看此属性返回的实体类型的元数据。我的猜测是此类型的 defaultResourceName 为 null。您可以通过 MetadataStore 为任何类型设置 defaultResourceName。

var custType = em1.metadataStore.getEntityType("PropertyDocument");
custType.setProperties( {
    defaultResourceName: "PropertyDocuments"
)};

另请参阅此页面上的“defaultResourceName”说明: http://www.breezejs.com/sites/all/apidocs/classes/EntityType.html

关于javascript - breezejs 导航刷新 "There is no resourceName for this query",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28754940/

相关文章:

javascript - Breeze : mixing EF context and IQueryable

日期时间范围的 OData 查询过滤器

javascript - 如何在可用时使 Angular.js 应用离线并与服务器同步

javascript - React router v4 渲染元素内的组件

javascript - Html.DropDownList 在 JSON 中使用 .val() 作为 null 传递

javascript - 尚未为上下文 : _. 加载 TypeScript 导出和导入模块名称使用 require([])

javascript - 带有 ionic 搜索栏焦点的 ionic 触发模式打开功能 - 单击不起作用

javascript - View 中的 Backbone 数据逻辑

javascript - Breeze 无法自动获取元数据

c# - 使用 POCO 和 ObjectCotext 来自 EFcontextprovider 的自定义元数据