如何使用“房间关系"获取其他pojo的列表 [英] How to use Room Relation to get a list of another pojo

查看:80
本文介绍了如何使用“房间关系"获取其他pojo的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@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
)

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

how to get a list of Benefit inside Subscription i.e.,

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

使用房间关系

推荐答案

您可以从 Google文档. 有一些有关房间中的关系"的示例.

You can find examples from Google Documents. There are examples about Relation in Room.

这篇关于如何使用“房间关系"获取其他pojo的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆