Get sorted data from sqlite table RRS feed

  • Question

  • Hi everbody, 

    I am using Sqlite database in my windows store application. I have configure it and succeeded in inserting, reading, updating and deleting record from specific data. But the problem I am facing is I want to get sorted data in ascending order with respect to column. 

    Below is the code I used to get complete table data 


                using (var db = new SQLite.SQLiteConnection(DatabasePath))
                    var found = db.Table<myTable>();

                    foreach (myTable records in found)


    This above code is working fine for getting data of whole table but I want sorted. Can anyone please suggest me that what would be added in this code to get sorted data from table or else I have to create logic for sorting data after getting in List by my own.



    Tuesday, January 28, 2014 6:23 AM


  • If you add a 'using System.Linq;' statement to the top of your file, then you can sort via Linq:

    var found = from m in db.Table<myTable>() orderby m.YourSortFieldHere select m;

    If you activate tracing with 'db.Trace = true;' you'll see that SQLite added an 'order by' to the query.

    Tuesday, January 28, 2014 7:51 AM