问题
I'm a beginner in Breeze and have a problem with the following situation I have the following model. A Person entity, can have multiple Projects assigned. A project can have multiple Tasks. And each Task has a Priority. I would like to get all the Persons which have at least one Project which has at least one Task with a Priority code 'High'.
I found I can use the 'any' or 'some' for working with 2nd level children.
var p1 = new breeze.Predicate.create('projects', 'some', 'client.code', 'Equals', 'ABC');
The above correctly returns Persons with Projects for Clients with code ABC. But in my case I would have to apply the 'any' one level deep, also to Tasks and I can't find the correct way of doing it. Thanks for any help
回答1:
You can nest multiple any/all using that syntax:
var query = breeze.EntityQuery.from('persons')
var p = new breeze.Predicate('projects', 'any', new breeze.Predicate('tasks','any','priority','>',1));
query = query.where(p);
You'll have to change the MaxAnyAllExpressionDepth
property of your controller to allow multiple any level:
[BreezeNHController(MaxAnyAllExpressionDepth = 5)]
来源:https://stackoverflow.com/questions/21775107/breeze-predicate-on-multiple-levels-of-children