在Kotlin中找到糖ORM记录

时间:2018-03-05 16:08:59

标签: java android kotlin sugarorm

我有Advertiser课程,在Kotlin中扩展SugarRecord

class Advertiser : SugarRecord<Advertiser> {
    var number: String? = null
    var name: String? = null

    constructor() {}

    constructor(number: String, name: String) {
        this.number = number
        this.name = name
    }
}

当我尝试通过Java查找记录时,它可以正常工作:

   Advertiser advertiser =  Advertiser.find(Advertiser.class, "number = ?", "123123").get(0);

但是当我将此代码转换为Kotlin时,我遇到了问题:

enter image description here

如何在Kotlin中执行查找?

1 个答案:

答案 0 :(得分:4)

你应该这样称呼它

SugarRecord.find(Advertiser::class.java, "number = ?", "123123").get(0)

希望它有所帮助!