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

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

deserializeDates

Specifies whether stores in the ODataContext serialize/parse date-time values.

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 to use JSONP to access CORS-incompatiable 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)

Invokes a WebGet service operation that returns a value.

invoke(operationName, params, httpMethod)

Invokes a WebGet service operation that returns nothing.

objectLink(entityAlias, key)

Gets a special proxy object to describe the entity link.