SAP OData 的 V2 模型
文檔地址:
https://sapui5.hana.ondemand.com/#/topic/6c47b2b39db9404582994070ec3d57a2#loio66a130fa4d10411b8fc90df00185554b
The OData model is a server-side model, meaning that the data set is only available on the server and the client only knows the currently visible (requested) data. Operations, such as sorting and filtering, are done on the server. The client sends a request to the server and shows the returned data.
OData 模型是一個服務器端模型,這意味著業務數據只在服務器端可用,客戶端只維護了其當前發出請求后,服務器端返回的部分數據。圍繞數據進行的排序和過濾等操作,都是先在服務器端執行,再將執行結果返回給客戶端。
Requests to the back end are triggered by list bindings (ODataListBinding), context bindings (ODataContextBinding), and CRUD functions provided by the ODataModel. Property bindings (ODataPropertyBindings) do not trigger requests.
目前 OData 模型通過如下 API 觸發向后臺的數據請求:
- List binding - ODataListBinding
- context binding - ODataContextBinding
- 增刪改查操作
The following two versions of the OData model are implemented:
- sap.ui.model.odata.ODataModel
- sap.ui.model.odata.v2.ODataModel.
The v2.ODataModel has an improved feature set and new features will only be implemented in this model.
sap.ui.model.odata.ODataModel is deprecated. We recommend to only use v2.ODataModel.
前者已經被標注成 deprecated 狀態,后者是 SAP 推薦使用的數據模型。
注意:OData V2 模型已經支持客戶端的排序和過濾了。
OData model 模型實例的創建方法:
var oModel = new ODataModel("http://services.odata.org/Northwind/Northwind.svc/"); var oModel = new ODataModel({serviceUrl: "http://services.odata.org/Northwind/Northwind.svc"});當模型實例創建時,自動觸發獲取 OData 服務元數據的請求:
http://services.odata.org/Northwind/Northwind.svc/$metadata
Only the first model instance triggers a $metadata request. A JSON representation of the service metadata can be accessed by calling the getServiceMetadata() method on an OData model instance.
JSON 格式的服務元數據,通過模型實例的 getServiceMetadata 方法返回。
var oMetadata = oModel.getServiceMetadata();In the v2.ODataModel, the service metadata is loaded asynchronously. It is not possible to load it synchronously. To get notified when the loading is finished, attach the metadataLoaded event.
對于 2.0 版本的 OData 模型來說,服務元數據采取一部方式加載,如果在應用程序里想捕捉元數據加載成功的事件,需要監聽 metadataLoaded 事件。
總結
以上是生活随笔為你收集整理的SAP OData 的 V2 模型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银行卡被风控了有什么影响 银行卡被风控了
- 下一篇: 如何处理使用 SAP UI5 消费真实的