DevExtreme Vue - ODataContext Methods
This section describes the methods that control the ODataContext.
get(operationName, params)
Invokes an OData operation that returns a value.
App.vue
- <script>
- import ODataContext from 'devextreme/data/odata/context';
- const context = new ODataContext({
- // ODataContext is configured here
- });
- export default {
- mounted() {
- this.products = context.get('GetProductsByRating', { rating: 3 });
- },
- // ...
- }
- </script>
See Also
invoke(operationName, params, httpMethod)
Invokes an OData operation that returns nothing.
Parameters:
App.vue
- <script>
- import ODataContext from 'devextreme/data/odata/context';
- const context = new ODataContext({
- // ODataContext is configured here
- });
- export default {
- mounted() {
- context.invoke('Add', { fieldName: 'fieldValue' }, 'POST');
- },
- // ...
- }
- </script>
See Also
objectLink(entityAlias, key)
Gets a link to an entity with a specific key.
Parameters:
Return Value:
An object that contains the link to the entity.
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:
App.vue
- <script>
- import ODataContext from 'devextreme/data/odata/context';
- const context = new ODataContext({
- url: 'http://www.example.com/Northwind.svc/',
- entities: {
- Orders: {
- key: 'Order_ID',
- keyType: 'Int32'
- },
- Customers: {
- key: 'Customer_ID',
- keyType: 'Int32'
- }
- }
- });
- export default {
- mounted() {
- context.Orders.update(1, {
- Customer: context.objectLink('Customers', 2)
- });
- },
- // ...
- }
- </script>