I'm trying to list the contents of a table, showing in each item the items of another table that maintains a relation 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 do not 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'm using cshtml and rasor page.