Use variable/function of parameter inside room query

Viewed 37

Currently I do following:

// Query with "direct" variables
@Query("select * from w_exercise where fk_exercise = :exerciseId")
protected abstract suspend fun loadAll(exerciseId: Long): List<WExercise.WExerciseWithRefs>

// forward function that converts the class to the desired variables
suspend fun loadAll(exercise: Exercise) = loadAll(exercise.id)

What I want is following instead:

@Query("select * from w_exercise where fk_exercise = :exercise.id")
protected abstract suspend fun loadAll(exercise: Exercise): List<WExercise.WExerciseWithRefs>

The used syntax does not work, is there a way to get it working and to use the variable of the class instance directly in the query?

0 Answers
Related