简体   繁体   English

如何转换RealmList <T> 到RealmResults <T>

[英]how to convert RealmList<T> to RealmResults<T>

I am working on realm database and want to convert RealmList to RealmResults. 我正在研究领域数据库,并且想要将RealmList转换为RealmResults。 The realmlist is attribute of realm object. 领域列表是领域对象的属性。

Simple use query on your list : 您列表上的简单查询:

class MyObject extends RealmObject {

    RealmList<MySubObject> subObjects;
}

...

myObject.subObjects.where().findAll(); //returns a RealmResults

//you can query your list like
myObject.subObjects
     .where()
     .equalTo("status", "done")
     .findAll(); //you can use sort, findFirst etc

It's very simple: 很简单:

RealmResults<T> results = realmList.where().findAll();

Please note that this only works on managed RealmList. 请注意,这仅适用于托管的 RealmList。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM