室:将列名作为DAO方法中的参数传递 [英] Room: pass columns Name as parameter in DAO Method
本文介绍了室:将列名作为DAO方法中的参数传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Room从本地Android sqlite数据库中查询表格.
I m using Room to query a table from my local Android sqlite database.
我已经创建了一个抽象类Dao,并且想知道是否可以像这样将列名作为方法中的参数传递:
I've created an abstract class Dao , and wondering if i can pass the name of columns as parameters in method like this :
@Query(value = "SELECT :columnName "
+ " from " + Constant.TABLE_NAME
)
public abstract Maybe<List<SomeEntity>> getResults(String columnName);
推荐答案
不,抱歉,不支持. Room仅支持SQLite所支持的功能,而SQLite不支持用于列名,表名等的参数.
No, sorry, that is not supported. Room only supports what SQLite does, and SQLite does not support parameters for column names, table names, etc.
这篇关于室:将列名作为DAO方法中的参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文