Filtering items in a products table

Asked

Viewed 44 times

1

Good afternoon to everyone, I have a simple application that I am developing, and I have the following problem, I have a variable "Tenure List", which already has the ID of the items, and I have a variable List that has all the registered Logs, I created a filtered variable to receive from inside the List List the items that are in the variableTowers, I have an example that I did but I am not able to filter.inserir a descrição da imagem aqui

  • 1

    listaItensToras is a type of data and c.AlceId is of another kind so the comparison is not accepted!

  • tried several ways but could not, friend has some suggestion ?

1 answer

0


Itenstoras must contain the property Alceid, so you can check if the Tora is in the list TensToras, so will be your foreach

foreach(var tora in listaToras)
{
   if(listaItensToras.Any(x => x.AlceId == tora.AlceId))
   {
      filtrados.Add(tora);
   }
}

To know if a certain value is present in a list we use the method .Any() library System.Linq that returns a true if the value exists within the list or false otherwise.

  • thank you very much friend, God bless you I will make the test here I believe that now it goes of right.

  • Oops, I hope for sure, don’t forget to brand as you accept the answer. Vlw

Browser other questions tagged

You are not signed in. Login or sign up in order to post.