3
I have the following problem: In a view I will show data from 8 different tables and I have the following code that I put together to take the data to the view.
public ActionResult Index()
{
var avisos = (from av in neEAD.mot_avisos
join tm in neEAD.mot_turma on av.av_tm_id equals tm.tm_id
join ta in neEAD.mot_turmaaluno on tm.tm_id equals ta.ta_tm_id
join al in neEAD.mot_aluno on ta.ta_al_id equals al.al_id
join tmp in neEAD.mot_turmaprofessor on tm.tm_id equals tmp.tp_tm_id
join pf in neEAD.mot_professor on tmp.tp_pf_id equals pf.pf_id
join pfd in neEAD.mot_professor_disciplina on pf.pf_id equals pfd.pfd_pf_id
join dp in neEAD.mot_disciplina on pfd.pfd_dp_id equals dp.dp_id
where (dp.dp_id == 1 && tm.tm_id == 4 && al.al_id == 22)
orderby av.av_datacadastro descending
select av).ToList();
return View(avisos);
}
Then I have a Join Inner to bring the data, but at the end in the select part I can only select the first table, and when I put so:
select new {
av.av_datacadastro,
av.av_mensagem,
av.av_titulo,
pf.pf_nome
}
My error code in the view. Is there any way I can put more than one model in the view? How do I use this?
Use a
ViewModel
– Jéf Bueno
Explain better, because I direct my view when creating to a specific model, but how do I specify more than 1 model?
– Deivid Farias