如何在 Breezejs 中使用 any() 创建 json 查询

How to create a json query in with any() in Breezejs

我正在尝试在 Breeze 中使用这个 json 谓词:

predicate.push({
        or: [
            { not: { relocationStates: { any: {} } } },
            { relocationStates: { any: { "state.id": { "eq": 11 } } } }
        ]
    });

not: {relocationStates: { any: {}}} 的目的是包含具有空 relocationStates 列表的所有项目。

这应该创建一个 odata URL 如下:

$filter=(not RelocationStates/any()) or (RelocationStates/any(x1: (x1/State/Id eq 11)))

上面的 oData URL 工作正常,但 breezejs 无法创建 URL 和错误:

TypeError: Cannot read property 'key' of null

是否可以在 Breezejs 中创建一个 json 查询,该查询将 return 提交列表为空的所有项目?

这似乎是一个错误。我在 Breeze 中 created an issue for it。您可以期待在下一个版本中进行修复。

一个粗略的解决方法是加入一些对 relocationStates 总是正确的子句,例如

{ not: { relocationStates: { any: { "id": { "ne": null } } } } }