Methods

This section describes the methods used to manipulate the ODataContext.

get(operationName, params)

Initiates the specified WebGet service operation that returns a value. For the information on service operations, refer to the OData documentation.

Parameters:
operationName:

String

The name of the operation to invoke.

params:

Object

The bag of parameters supported by the operation.

Return Value:

Promise<any> (jQuery or native)

A Promise that is resolved after the operation has completed. It is a native Promise or a jQuery.Promise when you use jQuery.

invoke(operationName, params, httpMethod)

Initiates the specified WebGet service operation that returns nothing. For the information on service operations, refer to the OData documentation.

Parameters:
operationName:

String

The name of the operation to invoke.

params:

Object

The bag of parameters supported by the operation.

httpMethod:

Object

Specifies the HTTP method for this operation. The default value is "POST".

Return Value:

Promise<void> (jQuery or native)

A Promise that is resolved after the operation has completed. It is a native Promise or a jQuery.Promise when you use jQuery.

objectLink(entityAlias, key)

Return a special proxy object to describe the entity link.

Parameters:
entityAlias:

String

The type name.

key:

Object

|

String

|

Number

The target entity key value.

Return Value:

Object

The desired proxy object.

This method is used within the insert() and update() method calls.

The following example demonstrates how to change the Category property of the Product entity with the key 1 to the Category with the key 2.

JavaScript
context.Products.update(1, {
    Category: context.objectLink("Categories", 2)
});

For more information on linking entities, refer to the Associations section of the Data Source Examples article.