Data Layer 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
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.

Methods

This section describes the methods used to manipulate the ODataContext.