问题
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.
回答1:
Given the predicate:
var predicateBarcode = Predicate.create('units','any','barcodes','any','barcode', 'eq', searchText());
I have added the MaxAnyAllExpressionDepth
property to my breeze controller :
[BreezeController(MaxAnyAllExpressionDepth = 2)]
Thanks to @lnu..
来源:https://stackoverflow.com/questions/21970720/breezejs-predicates-on-2nd-level-expanded-entities