odata - 如何使用 oModel.createEntry 创建深层实体

标签 odata sapui5

有没有办法使用 oModel.createEntity() 创建一个“临时”(或者我猜它被称为虚拟)深层实体?

我有一个名为 Timesheet 的实体,它与中断有关联,称为 ToBreaks。

现在我想通过使用在前端创建一个新实体oModel.createEntity("/TimesheetSet")

不幸的是,在所谓的虚拟新条目中,我的所有关联都丢失了。
因为我使用assications来绑定(bind)表,所以在创建虚拟新条目后,会触发后端调用TimesheetSet("id-04-123456789")/ToBreaks 导致“无效的键谓词”错误。

有没有办法用 OData V2 做到这一点?

更新 09.08.2016:

You can still try by just using the properties parameter with a nested entity set. As long as your OData service supports the corresponding deep create it should work:



我也尝试过这样的事情:
oModel.createEntry("/TimesheetEntry", {
    Pernr: sPernr,
    Begda: dBegda,
    ToBreaks: [{
        Pernr: sPernr,
        Begda: dBegda
    }]
});
ToBreaks 是关联的名称。

在 OData 模型的虚拟条目中,关联的属性仍然缺失。我可以使用上面的代码创建新条目,但之后没有名为 ToBreaks 的属性

在后端,我按照本教程实现 deep_create 方法:step-by-step-development-guide-for-createdeepentity-operation。我能够从 SAP 网关客户端中触发该方法。

最佳答案

来自 API docs :

Please note that deep creates (including data defined by navigationproperties) are not supported.



您仍然可以尝试使用 properties具有嵌套实体集的参数。只要您的 OData 服务支持相应的深度创建,它就应该可以工作:

properties could be an object which includes the desired properties and the values which should be used for the created entry.

关于odata - 如何使用 oModel.createEntry 创建深层实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38802780/

相关文章:

javascript - SAPUI5 表 : unbindRows & destroyColumns cause error: Cannot read property 'shouldRender' of undefined

javascript - SAPUI5 : Process Flow control is not working on different language setting

c# - 如何查看从本地主机到 CRM 的流量?

sql - 如何将 SQL 查询转换为 Odata 查询

javascript - SAPUI5:带参数的路由 - 如何获取绑定(bind)上下文的正确路径

sapui5 - 导航时不触发函数 onExit

sapui5 - UI5 路由 View 按预期绑定(bind)元素,但无法正确找到路径

wcf - 访问 OData 服务给出 404 "Resource not found error"

odata - OData查询是否支持使用AND/OR运算符嵌套的过滤器?

c#-4.0 - 未找到使用模板 '~/entityset'为OData路径选择操作的路由约定