[英]ObjectBox - ToMany Conditions
I have the following code, which selects everything in AEntity.我有以下代码,它选择 AEntity 中的所有内容。
Box<AEntity> a = boxStore.boxFor(AEntity.class);
return new ObjectBoxLiveData<AEntity>(a.query().build());
AEntity has a ToMany relationship with BEntity: AEntity 与 BEntity 具有 ToMany 关系:
@Backlink(to = "aEntity")
private ToMany<BEntity> bEntities;
I would like to select everything in AEntity as shown above while checking a property of BEntity.在检查 BEntity 的属性时,我想 select 中的所有内容,如上所示。 The ideal code would look something like this:理想的代码如下所示:
Box<AEntity> a = boxStore.boxFor(AEntity.class);
return new ObjectBoxLiveData<AEntity>(a.query().notEqual(BEntity_.bproperty, "-1").build());
Basically I am saying: "I want everything from AEntity
as long as bproperty
isn't "-1"
.基本上我是在说:“只要bproperty
不是"-1"
,我就想要AEntity
的一切。
Of course, this doesn't work but is there a way I could achieve this behavior?当然,这不起作用,但有没有办法可以实现这种行为?
Did you try adding a link query for the related entity BEntity
?您是否尝试为相关实体BEntity
添加链接查询? Something like:就像是:
queryBuilderA = a.query();
queryBuilderA.link(AEntity_.relation).notEqual(BEntity_.bproperty, -1);
queryBuilderA.build();
https://docs.objectbox.io/queries#add-query-conditions-for-related-entities-links https://docs.objectbox.io/queries#add-query-conditions-for-related-entities-links
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.