Adel Sal
Adel Sal

Reputation: 718

BreezeJS Predicates on 2nd level expanded entities

A similar question has been asked on this matter: Breeze work-around for multi valued property queries

Well, that works for one-one-many. i.e parent entity may have one child which in turn has many children.

My scenario is : A product has many units, a particular unit has many barcodes.

var predicateBarcode = Predicate.create('units.barcodes','any','barcode', 'eq', searchText());

 var query = EntityQuery.from('Products')
             .expand('units.barcodes')
             // .take(10)
             .where(predicateBarcode );
            return manager.executeQuery(query)
                .then(querySucceeded)
                .fail(queryFailed);

Executing the Query gives an error:

The parent value for a property access of a property 'barcodes' is not a single value. Property access can only be applied to a single value.

I've changed the predicate to:

var predicateBarcode = Predicate.create('units','any','barcodes','any','barcode', 'eq', searchText());

which gives another error:

The Any/All nesting limit of '1' has been exceeded. 'MaxAnyAllExpressionDepth' can be configured on ODataQuerySettings or QueryableAttribute

Is there any way around this? Help is appreciated.

Upvotes: 2

Views: 1418

Answers (1)

Adel Sal
Adel Sal

Reputation: 718

Given the predicate:

var predicateBarcode = Predicate.create('units','any','barcodes','any','barcode', 'eq', searchText());

I have added the MaxAnyAllExpressionDepthproperty to my breeze controller :

[BreezeController(MaxAnyAllExpressionDepth = 2)]

Thanks to @lnu..

Upvotes: 3

Related Questions