Converts a SQL query to Query in Entity

3

I asked this question in another forum, but the content of the discussion followed another way so I decided to open this topic. Without skipping the subject, how do I perform this SQL query:

select p.RA, p.Nome, p.Modulo, a.Descricao
from inscricao as i, participante as p, Atividade as a 
where i.ParticipanteId = p.ParticipanteId and 
   i.AtividadeId = a.AtividadeId order by p.Modulo

In a query using Entity?

    
asked by anonymous 15.09.2017 / 14:43

1 answer

1

Try to do as follows.

var query = (from i in dbContext.inscricao
                     join p in dbContext.participante on i.ParticipanteId equals p.ParticipanteId
                     join a in dbContext.Atividade on p.AtividadeId equals a.AtividadeId
                     where i.periodo == ViewModel.periodo && i.data == ViewModel.data.
                     select new {
                         RA = p.RA,
                         Nome = p.Nome,
                         Modulo = p.Modulo,
                         Descricao = a.Descricao
                     })
                     .OrderBy(x => x.Modulo);
    
15.09.2017 / 15:29