JayData.org

Groundbreaking OData V4 features in JayData 1.5.1 CTP

Author: Robert Bonay March 11th, 2016

,


There is no question: our goal is to build the the best OData v4 JavaScript tool, ever. There are a lot things to improve, but we release our next Community Technology Preview to show our latest results.

How to try the new OData v4 features

We published an OData v4 service endpoint backed by WebAPI OData, horray.

Thanks to JaySvcUtil, you can pre-generate your data model in node.js command prompt.

Arrow function support

JayData has improved predicates in Queryables. You can use arrow functions for example in filter conditions.
Old style

New style – using arrow function

If arrow function isn’t supported by your targeted browsers (older IE) then you can use it in string

Advanced retrieval of related entities through $expand

You can use additional queryable methods on collections to filter/project navigation properties with arrays
Filtering array-valued navigation properties

Projecting array-valued navigation properties

Projecting and filtering array-valued navigation properties

Expanding navigation properties of navigation properties

Basic retrieval:

Retrieval of multiple navigation properties at the same level

Expanding pre-filtered navigation properties – result: you will get a list of categories that has a prefiltered article list that match the filter criteria; all article record will be loaded with Tags and Reviewer properties and its values:

Available nested queryable methods:

  • filter
  • map
  • orderBy
  • orderByDescending
  • take
  • skip

Deep insert

You can enable deep insert behavior through the following global configuration property in JayData
$data.defaults.OData.enableDeepSave

If true (default: false) then the provider will discover the deeply insertable entities to reduce the created request numbers

The result will be only one POST request.
Technical depth: computed fields (such as auto-incremented IDs) of deep-inserted entities aren’t returned by current version of ASP.NET WebAPI OData

Function parameter resolution (isn’t enabled by default yet)

There is an other usage of parameters in Queryable predicates
Old style

New style

You can use function parameters in arrow functions, so it is equivalent with:
ctx.Articles.filter((it, p1, p2) => it.Title == p1 && it.Lead == p2 }, {p1: ‘Title’, p2: ‘Lead’})
To enable this feature with the following global setting (default: true) :
$data.defaults.parameterResolutionCompatibility = false;

Managing entity relationships

Creating a relationship between entities in .NET

How to set entity references in JayData

There is a global configuration property: $data.defaults.OData.withReferenceMethods
If true (true by default) then OData provider provider will create an additional POST request what handled by this CreateRef action to set navigation property while calling saveChanges() method

Removing a relationship between entities

How to remove relationships between entities in JayData
There is a configuration property
$data.defaults.OData.withReferenceMethods

If true (default: true) then the provider will create an additional DELETE request what handled by this DeleteRef action to clear navigation property while calling saveChanges() method

Download JayData 1.5.1 CTP and try all these features!


,