Methods

This section describes the methods used to manipulate the ODataContext.

get(operationName, params)

Invokes a WebGet service operation that returns a value.

Parameters:
operationName:

String

The operation's name.

params:

Object

The operation's parameters.

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)

Invokes a WebGet service operation that returns nothing.

Parameters:
operationName:

String

The operation's name

params:

Object

The operation's parameters.

httpMethod:

Object

The HTTP method for this operation. "POST" by default.

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)

Gets 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 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.