yan cus

yan cus

  • 1.9k
  • 119
  • 613

How load and view first item from xamarin sql database in C#

Jan 28 2021 8:01 AM
I use helper code below to get the first ID from MyTable but an error. How should this code be made accessible?
  1. public Task<MyTable> GetLastTableItem(int id)  
  2. {  
  3.     return _db.Table<MyTable>().Where(i => i.ID == id).FirstOrDefaultAsync();  
  4. }  
Then I want to display it in label. How should this be made?
  1. void GetLastItem(object sender, EventArgs e)  
  2. {  
  3.     Label label = new Label();
  4.     label.Text = bla''bla''bla.GetLastTableItem();  
  5. }  

Answers (3)