DevExtreme jQuery - ODataContext API
This object creates several ODataStore instances. Each instance accesses an individual entity collection.
jQuery
var context = new DevExpress.data.ODataContext({ url: "http://www.example.com/Northwind.svc", entities: { Categories: { key: "CategoryID", keyType: "Int32" }, // An entity collection alias Clients: { name: "Customers", key: "CustomerID", keyType: "String" }, Products: { // A composite key key: ["ProductID", "ProductCode"], keyType: { ProductID: "Guid", ProductCode: "Int32" } } } });
Angular
import ODataContext from "devextreme/data/odata/context"; // ... export class AppComponent { context: ODataContext; constructor () { this.context = new ODataContext({ url: "http://www.example.com/Northwind.svc", entities: { Categories: { key: "CategoryID", keyType: "Int32" }, // An entity collection alias Clients: { name: "Customers", key: "CustomerID", keyType: "String" }, Products: { // A composite key key: ["ProductID", "ProductCode"], keyType: { ProductID: "Guid", ProductCode: "Int32" } } } }); } }
Vue
<script> import ODataContext from 'devextreme/data/odata/context'; const context = new ODataContext({ url: 'http://www.example.com/Northwind.svc', entities: { Categories: { key: 'CategoryID', keyType: 'Int32' }, // An entity collection alias Clients: { name: 'Customers', key: 'CustomerID', keyType: 'String' }, Products: { // A composite key key: ['ProductID', 'ProductCode'], keyType: { ProductID: 'Guid', ProductCode: 'Int32' } } } }); export default { // ... } </script>
React
// ... import ODataContext from 'devextreme/data/odata/context'; const context = new ODataContext({ url: 'http://www.example.com/Northwind.svc', entities: { Categories: { key: 'CategoryID', keyType: 'Int32' }, // An entity collection alias Clients: { name: 'Customers', key: 'CustomerID', keyType: 'String' }, Products: { // A composite key key: ['ProductID', 'ProductCode'], keyType: { ProductID: 'Guid', ProductCode: 'Int32' } } } }); class App extends React.Component { // ... } export default App;
A 1-Click Solution for CRUD Web API Services with Role-based Access Control via EF Core
If you target .NET for your backend API, be sure to check out Web API Service and register your free copy today. The Solution Wizard scaffolds an OData v4 Web API Service (.NET 6+) with integrated authorization & CRUD operations powered by EF Core ORM. You can use OAuth2, JWT or custom authentication strategies alongside tools like Postman or Swagger (OpenAPI) for API testing. The built-in Web API Service also filters out secured server data based on permissions granted to users. Advanced/enterprise functions include audit trail, endpoints to download reports, file attachments, check validation, obtain localized captions, etc.
To use the free Solution Wizard (which creates the Web API Service), run the Universal Component Installer from the DevExpress Download Manager and use our predefined template in Visual Studio 2022+.
Read Tutorial | View Examples: JavaScript (DevExtreme) & JavaScript (Svelte) | Watch Videos
See Also
Options
Name | Description |
---|---|
beforeSend |
Specifies a function that customizes the request before it is sent to the server. |
deserializeDates |
Specifies whether stores in the ODataContext serialize/parse date-time values. |
entities |
Specifies entity collections to be accessed. |
errorHandler |
Specifies a function that is executed when the ODataContext throws an error. |
filterToLower |
Specifies whether to convert string values to lowercase in filter and search requests. Applies to the following operations: "startswith", "endswith", "contains", and "notcontains". |
jsonp |
Specifies whether data should be sent using JSONP. |
url |
Specifies the URL of an OData service. |
version |
Specifies the OData version. |
withCredentials |
Specifies whether to send cookies, authorization headers, and client certificates in a cross-origin request. |
Methods
Name | Description |
---|---|
get(operationName, params) |
Invokes an OData operation that returns a value. |
invoke(operationName, params, httpMethod) |
Invokes an OData operation that returns nothing. |
objectLink(entityAlias, key) |
Gets a link to an entity with a specific key. |
If you have technical questions, please create a support ticket in the DevExpress Support Center.