简体   繁体   中英

GreenDAO QueryBuilder dynamically concatenate conditions

I need to verify some conditions to create a complete query:

QueryBuilder<MyObj> qb = getMyObjDao().queryBuilder();

if ( someCondition )
     qb.where(MyObjDao.Properties.Prop1.eq(someValue));
else       
    qb.whereOr(MyObjDao.Properties.Prop2.eq(someValue),MyObjDao.Properties.Prop2.eq(someValue));

if ( someOtherCondition )
     qb.where(MyObjDao.Properties.Prop3.eq(someValue));
else
     qb.whereOr(MyObjDao.Properties.Prop4.eq(someValue));

So is it possible to concatenate query builder conditions and create query builder dynamically?

In general, it's possible to create dynamic queries using QueryBuilder.

Does this already answer your question? If you have issues, please be more specific.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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