Sponser Link

Select query in SQLite Xamarin forms

In this tutorial, we will fetch the data from table, the given below method will return the list of employee class object. You can write query with filters as per your requirement, but given below function will return all data of employee table.

  public Task> GetEmployeeAsync()
  {
     return _db.Table().ToListAsync();
  }

Now you can call this method for retrieve the data. Given below code is example for read all data in loop.

    var emp = await App.EmpDB.GetEmployeeAsync();
    string str_EmpNo;
    string str_userName;

            foreach (var e in emp)
            {
                str_EmpNo = e.EmpNo;
                str_userName = e.UserName;
            }