[Android] SQLite IN 运算符在 Room 中的用法

假设 SQL 为:

SELECT * FROM nfc WHERE site_id IN (1,2);
@Query("SELECT * FROM nfc WHERE site_id IN (:siteIDs)")
fun getAllBySites(
    siteIDs: String = "1,2"
): List<Nfc>
@Query("SELECT * FROM nfc WHERE site_id IN (:siteIDs)")
fun getAllBySites(
    siteIDs: List<String> = listOf(1,2)
): List<Nfc>

@Query("SELECT * FROM nfc WHERE site_id IN (:siteIDs)")
fun getAllBySites(
    siteIDs: Array<String> = arrayOf(1,2)
): List<Nfc>

发表评论


*