Room DAO Order By ASC or DESC variable

前端 未结 3 2269
半阙折子戏
半阙折子戏 2021-02-18 17:48

I\'m trying to make a @Query function in my @Dao interface which has a boolean parameter, isAsc to determine the order:

@Q         


        
3条回答
  •  鱼传尺愫
    2021-02-18 18:20

    Why don't you try something like this? I have not tested it.

    @Query("SELECT * FROM Persons ORDER BY first_name :order")
    List getPersonsAlphabetically(String order);
    

    And the logic you suggested should go before you make the query.

提交回复
热议问题