GreenDao集成教程(三) DB高级查询

高级查询

//高级查询

/**
 * 提交标准SQL到DB查询
 */
public void query1(){
    List list = manager.getDaoSession().queryRaw(Member.class,"where MEM_NAME like ? and _id > ?",new String[]{"%张三%","50"});
    Logger.d(list.toString());
}

/**
 * 提交QueryBuilder到DB查询
 */
public void query2(){
    QueryBuilder builder = manager.getDaoSession().queryBuilder(Member.class);
    List list = builder.where(MemberDao.Properties.MemSex.ge(99)).list();
    Logger.d("QueryBuilder-->"+list.toString());
}

/**
 * 提交QueryBuilder到DB查询
 */
public void query3(){
    QueryBuilder builder = manager.getDaoSession().queryBuilder(Member.class);
    List list = builder.whereOr(MemberDao.Properties.MemSex.le(30),MemberDao.Properties.MemName.like("张三1%")).list();
    Logger.d("QueryBuilder-->"+list.toString());
}

DEMO入口

你可能感兴趣的:(GreenDao集成教程(三) DB高级查询)