【问题标题】:How to use Room Relation to get a list of another pojo如何使用 Room Relation 获取另一个 pojo 的列表
【发布时间】:2018-11-07 04:56:40
【问题描述】:
@Entity(tableName = "subscription")
data class Subscription(
    @PrimaryKey val planId: Int,
    @ColumnInfo(name = "plan_name") val planName: String? = null,
    @ColumnInfo(name = "plan_description") val planDescription: String? = null,
    @ColumnInfo(name = "plan_reg_fee") val planRegFee: String? = null,
    @ColumnInfo(name = "plan_monthly_charge") val planMonthlyCharge: String? = null
)


data class Benefit(
    @ColumnInfo(name = "benefit_id") val benefitId: Int? = null,
    @ColumnInfo(name = "benefit_code") val benefitCode: Int? = null,
    @ColumnInfo(name = "benefit_name") val benefitName: String? = null,
    @ColumnInfo(name = "benefit_status") val benefitStatus: String? = null
)

如何获取订阅中的福利列表,即,

val benefitList: LiveData<List<Benefit>>? = null

使用房间关系

【问题讨论】:

标签: android foreign-keys android-room


【解决方案1】:

您可以从Google Documents 中找到示例。 有一些关于房间关系的例子。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-01-07
  • 1970-01-01
  • 1970-01-01
  • 2011-10-13
  • 1970-01-01
  • 2021-10-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多