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: jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the operation has completed.

For more information, refer to the Invoking Service Operations documentation section.

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: jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the operation has completed.

For more information, refer to the Invoking Service Operations documentation section.

objectLink(entityAlias, key)

Return a special proxy object to describe the entity link.

Parameters:
entityAlias: String

The type name.

key: Object

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.