ODataContext

Provides access to the entire OData service.

Included in: dx.mobile.js, dx.web.js, dx.viz.js, dx.viz-web.js, dx.all.js
Export: default
Type:

Object

The ODataContext object creates several ODataStore instances inside. Each of these instances accesses a separate entity. To create an ODataContext instance, pass the configuration object to the ODataContext constructor. Specify the service URL and the list of entities you need to access.

JavaScript
var context = new DevExpress.data.ODataContext({
    url: "http://www.example.com/Northwind.svc",
    entities: {
        Categories: {
            key: "CategoryID",
            keyType: "Int32"
        },
        MyCustomers: {
            name: "Customers",
            key: "CustomerID",
            keyType: "String"
        }
    }
});

If you need to specify a composite key for an entity, assign an array of key expressions to the key option. In this case, the keyType option takes on an object providing corresponding properties for each key expression, as demonstrated in the following example.

JavaScript
var context = new DevExpress.data.ODataContext({
    url: "http://www.example.com/Northwind.svc",
    entities: {
        Products: {
            key: [ "ProductID", "ProductCode" ],
            keyType: {
                ProductID: "Guid",
                ProductCode: "Int32" 
            }
        }
    }
});

The ODataContext object also includes the get() and invoke() methods used to invoke service operations, and the objectLink() helper method to link entities.

For more information on working with OData, refer to the Data Source Examples article.

Configuration

This section describes configuration options used to configure the ODataContext.

Name Description
beforeSend

A function used to customize a web request before it is sent.

deserializeDates

Specifies whether or not dates in a response are deserialized.

entities

Specifies the list of entities to be accessed with the ODataContext.

errorHandler

Specifies the function called if the ODataContext causes an error.

jsonp

Specifies whether the ODataStore uses the JSONP approach to access non-CORS-compatible remote services.

url

Specifies the URL of the data service being accessed via the current ODataContext.

version

Specifies the version of the OData protocol used to interact with the data service.

withCredentials

Specifies the value of the withCredentials field of the underlying jqXHR object.

Methods

This section describes the methods used to manipulate the ODataContext.

Name Description
get(operationName, params)

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

invoke(operationName, params, httpMethod)

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

objectLink(entityAlias, key)

Return a special proxy object to describe the entity link.