如何将数据对象从房间关系转换为Android Kotlin中的自定义父子-Child类型对象
假设我有两个桌子父母和孩子。
当我们在这两个表上申请加入(类似)时, 这两个表的关系。但这返回包含父和子数据的对象列表。但是模型对嵌套回收器视图的要求是这样的亲子对象。 parent Model 儿童模型
因此,主要问题是在将关系应用于父母的关系后转换列表 -儿童类型列表。
我是一个新鲜的,并且对房间DB的了解不多,如果我遵循错误的方式,请让我纠正它。
谢谢。
Suppose I have two tables Parent and child.
This is the Parent Table Schema
This is the Child Table schema
when we apply to join(Relation) on these two table like this
Relation on these two tables. But this returns a list of objects that contain both parent and child data. But the requirement of the model for nested recycler view is the parent-child object like this.
Parent Model
Child Model
So, the main problem is to convert the list getting after applying relation to the parent-child type list.
I am a fresher and not so much knowledge about Room DB, if I follow some wrong way please let me correct it.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
替换父母和孩子的关系:
现在您可以将其转换为父模型,更改为数据类:
Replace parent and child in relation:
Now you can convert it to your Parent Model, changed to data class: