I have a LINQ expression where the result is saved in the query variable, which is transformed into a list, this query returns a series of "RA" attributes. p>
I would like to pass this list of attributes as a parameter in the LINQ expression resulting in query2
. I want query2
to return all the discipline codes in which these "RA" are related (Yes, I want to pass all of them at once).
I did the form below but did not get results, the code compiled, but it did not work. How do I pass the query
as a parameter in where
? Should I convert this list from 1 a single attribute to a common type? How do I?
void cargarDados(Int32 disc)
{
List<Turma> turmas = db.GetCollection<Turma>("turma").FindAll().ToList();
var query = (from t in turmas
where t.COD_DISCIPLINA == disc
select new
{
t.RA
}).ToList();
var query2 = (from t1 in turmas
where t1.COD_DISCIPLINA.Equals(query)
select new
{
t1.COD_DISCIPLINA
}).ToList();
dataGridView1.DataSource = query2;
}