Room DAO Order By ASC or DESC variable

前端 未结 3 1653
旧时难觅i
旧时难觅i 2021-02-18 18:08

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:31

    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.

提交回复
热议问题