1
I am trying to list the contents of a table, showing in each item the items of another table that maintains a relationship with the first (1:N). For this I need 2 select, being the 2nd select based on each line of the result of the 1st select. The problem is that I don’t know how to identify, inside the SELECT string, the value brought by the RASOR relative to the id field.
@{
string query = "SELECT id, tituloTopico FROM Topicos";
var resultados = base_dados.Query(query);
foreach (var linha in resultados)
{
@linha.tituloTopico
string query1 = "SELECT tituloCatalogo FROM Catalogos WHERE Catalogos.id_Topico = @linha.id";
var resultados1 = base_dados.Query(query1);
foreach (var linha1 in resultados1)
{
@linha1.tituloCatalogo
}
}
}
@line.id is not recognized within the Select statement. I am using cshtml and rasor page.
Don’t do this, this kind of processing should be on controller (assuming you’re using MVC.
– Maniero