DevExtreme React - ODataContext Methods
get(operationName, params)
A Promise that is resolved after the operation has completed. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
JavaScript
var context = new DevExpress.data.ODataContext({ // ODataContext is configured here }); var products = context.get("GetProductsByRating", { rating: 3 });
Angular
TypeScript
import ODataContext from "devextreme/data/odata/context"; // ... export class AppComponent { context: ODataContext; constructor() { this.context = new ODataContext({ // ODataContext is configured here }); let products = this.context.get("GetProductsByRating", { rating: 3 }); } }
See Also
invoke(operationName, params, httpMethod)
Parameters:
A Promise that is resolved after the operation has completed. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
JavaScript
var context = new DevExpress.data.ODataContext({ // ODataContext is configured here }); context.invoke("Add", { fieldName: "fieldValue" }, "POST");
Angular
TypeScript
import ODataContext from "devextreme/data/odata/context"; // ... export class AppComponent { context: ODataContext; constructor() { this.context = new ODataContext({ // ODataContext is configured here }); this.context.invoke("Add", { fieldName: "fieldValue" }, "POST"); } }
See Also
objectLink(entityAlias, key)
Parameters:
Return Value:
Call this method within the insert() or the update() method to change the relationships between entities. The following code links the order with ID 1
to the customer with ID 2
:
jQuery
JavaScript
var context = new DevExpress.data.ODataContext({ url: "https://js.devexpress.com/Demos/DevAV/odata/", entities: { Orders: { key: "Order_ID", keyType: "Int32" }, Customers: { key: "Customer_ID", keyType: "Int32" } } }); context.Orders.update(1, { Customer: context.objectLink("Customers", 2) });
Angular
TypeScript
import ODataContext from "devextreme/data/odata/context"; // ... export class AppComponent { context: ODataContext; constructor() { this.context = new ODataContext({ url: "https://js.devexpress.com/Demos/DevAV/odata/", entities: { Orders: { key: "Order_ID", keyType: "Int32" }, Customers: { key: "Customer_ID", keyType: "Int32" } } }); this.context.Orders.update(1, { Customer: context.objectLink("Customers", 2) }); } }
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.