代码之家  ›  专栏  ›  技术社区  ›  Glenncito

如何使用SugarRecord&Kotlin查询多子句参数

  •  0
  • Glenncito  · 技术社区  · 6 年前

    termList = SugarRecord.find(Term::class.java, "type = ? AND category = ?", "hcp, "+ parentCategoryId.toString())
    

    谢谢!

    1 回复  |  直到 6 年前
        1
  •  1
  •   Akaki Kapanadze    6 年前

    例如:

    val termList = SugarRecord.find(Term::class.java,
                    "type = ? and category = ?", // where clause
                    "hcp", parentCategoryId.toString()) // arguments
    

    另外,你可以使用 查询生成器 :

    val termList = Select.from(Term::class.java).where(
            Condition.prop("type").eq("hcp"), // type =(equals) ?
            Condition.prop("category").eq(parentCategoryId.toString())).list()
    

    http://satyan.github.io/sugar/query.html