4
I registered my products in a particular restaurant. Being Restaurant(1) and Products(N), I have several products registered in a restaurant.
How do I list these products for each restaurant?
This is the standard Action:
public ActionResult Cardapio()
{
return View(db.Produtos.ToList());
}
The logic you used is the one I really needed! But my id up there is null. I need to see what this is.
– Allan Fernandes
Because I access a list of restaurants, and I click on the details, and I go to his menu. Can you tell me if there’s some kind of mistake along the way?
– Allan Fernandes
Use as follows: http://localhost:porta/Restaurants/Cardapio/1
– Leonel Sanches da Silva
In detail:
@Html.ActionLink("Cardápio", "Cardapio", "Restaurantes", new { id = Model.RestauranteId })
. If that’s what I understand.– Leonel Sanches da Silva
Wow, true! haha A mistake I had made before at the beginning of the project. Thank you very much, Gypsy! = D
– Allan Fernandes
@Ciganomorrisonmendez, when we use Include it makes a JOIN in the query that goes to the right bank, but how does it look when using Firstofdefault ? it generates a list of Products with only one Restaurants?
– Marco Souza
@Exact Gokussjgod. Brings a restaurant with all its products, as advance charge (Join).
– Leonel Sanches da Silva