How to bring an item list

Asked

Viewed 97 times

4

I need to bring up a list of ITEMS, with only the Order id. The way I do it is this, but it brings me only one Item, I want to be able to bring all the items I have, with the Order ID.

var listaItems = new ItemRepositorio().BuscarTodos().FirstOrDefault(c => c.PedidoId == Id);
  • Friend in your ItemRepositorio() does not have a method to do this! What is the code of your ItemRepositorio() and the Entity! classes improve your question, because you may be making improper use of this code!

2 answers

0


  public List<ClasseUsada> FindAll(int pedidoId)
    {
        using (Conexao con = new Conexao())
        {
            return con.Tabela.Where(x=>x.Pedidoid.equals(pedidoid)).ToList();
        }
    }

Good afternoon follow code with this code returns everyone who has passed id

0

Just exchange your Firstordefault for Where.

The Firstordefault returns the first object establishing or not a condition, whereas the Where return all objects found in the condition.

  • Thanks so much for banging my head, I hadn’t even paid attention to Where. Thank you !!

Browser other questions tagged

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