Monday, 8 February 2021

Android Room getting count of elements in an 'incoming foreign key list' in an 'embedded entity'?

I have 2 Entities, Grade and Student, Student is having a foreign key towards the class room. Embedded entity ClassRoom looks like this,

data class ClassRoom(

    @Embedded
    val level: ClassLevel

    @Relation(
        parentColumn = "id",
        entityColumn = "ClassLevel"
    )
    val students: List<Student>,

    // val strength: Int ?

) 

What I am trying to achieve is, using ClassRoomInstance.strength to get the count of incoming foreign keys. Than calculating the sizes of students with students.size

What is the way to achieve this?

Thanks



from Android Room getting count of elements in an 'incoming foreign key list' in an 'embedded entity'?

No comments:

Post a Comment