Pass parameter for @DatabaseView in Room Database Android

729 Views Asked by At

I m having a databaseView code like this.

@DatabaseView("SELECT * FROM Product")
data class ProductDatabaseView(
    var productCode: String? = "",
    var productName: String? = "",
    var longDescription: String? = "",
    var productUom: String? = "",
    var customerCode: String? = "",
    var price: String? = ""
)

And I wanna pass some value as we do in our DAO like this.

@DatabaseView("SELECT * FROM Product WHERE priceListCode = :priceListCode")
data class ProductDatabaseView(
    var productCode: String? = "",
    var productName: String? = "",
    var longDescription: String? = "",
    var productUom: String? = "",
    var customerCode: String? = "",
    var price: String? = ""
)

Is it able to pass value like this or is there any other option available with the help of View.

1

There are 1 best solutions below

0
On

To my knowledge, no you can't pass argument to @DatabaseView. They work the same way as in sqlite which doesn't allow parameters in views.