How do I build a GreenDao query that loads all Items specified through a list of ids?

Janusz picture Janusz · Jan 7, 2013 · Viewed 8.5k times · Source

I have a List of Strings each String is a unique identifier for a item persisted through GreenDao.

How do I build a query that allows me to load all this items form my database?

Is there a possibility to do it with a QueryBuilder or do I need to go back to writing SQL?

Answer

Janusz picture Janusz · Jan 9, 2013

This is possible with the in condition in the Property class.

This example loads all boxes with field values contained in fieldValues. fieldValues is of the type List<String>

  List<LocalBox> boxes = getBoxDao(context).queryBuilder()
        .where(LocalBoxDao.Properties.field.in(fieldValues)).list();