Home > other >  How can I display certain rows of a data table?
How can I display certain rows of a data table?

Time:06-29

When displaying my CollectionView (which contains the data), I would like to display only the rows that have the field "Number" = xx

Currently I display my data like this:

public async Task<List<DB_PosteNF>> ListerPF()
{
  try
  {
     return await connection.Table<DB_PosteNF>().ToListAsync();
  }
  catch (Exception ex)
  {
      StatutMessage = $"Impossible d'afficher la liste des postes de frais. \nErreur : {ex.Message}";
  }
      return new List<DB_PosteNF>();
}

Here is the structure of my tables, I would like Primary Key number = Foreign Key

Table 1: Primary Key = Number

Table 2: Primary Key = Id Foreign key = Number

CodePudding user response:

Use LINQ

connection.Table<DB_PosteNF>().Where(x => x.Number == SomeValue).ToListAsync();

Replace SomeValue with value you want to filter by

  • Related