How to bring an item list

Posted on

Question :

I need to get a list of ITEMS , with just the Order id. The way I do is this, but it just brings me an 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);

    

Answer :

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

Good afternoon follows code with this code returns all that have passed id

    

Just swap your FirstOrDefault for Where.

The FirstOrDefault returns the first object whether or not to set a condition, since Where returns all objects found in the condition.

    

Leave a Reply

Your email address will not be published. Required fields are marked *