Breeze predicate on multiple levels of children

感情迁移 提交于 2019-12-11 02:59:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!