Group by with Lillo

Asked

Viewed 195 times

4

I have the following tables:

**Aula**
Id
Nome
Data

**Avaliacao**
Aula_Id
Aluno_Id
Organizacao
Didatica

To get a Join of the tables I use the code:

var result = from a in mdc.SBE_AA_Aulas
             join av in mdc.SBE_AA_AvaliacaoAlunos on a.id equals av.SBE_AA_Aula_id

             select new
             {
               a,
               av
             };

Where Organization and Didactic are the notes.

I would like a consultation through Ingli, which brings an average of the Organization and Didactic of each class.

But I can’t do it.

  • 1

    You have an initial code where you get the objects of lessons and evaluations?

  • I added in the post!

1 answer

5


That’s how it works, but I’m not sure it’s the best way:

var result = from a in mdc.SBE_AA_Aulas
            join av in mdc.SBE_AA_AvaliacaoAlunos on a.id equals av.SBE_AA_Aula_id
            group new {a, av} by av.Aula_Id into grp
            select new {
                NomeAula = grp.Select(x => x.a.Nome).FirstOrDefault(),
                MediaOrganizacao = grp.Average(x => x.av.Organizacao),
                MediaDidatica = grp.Average(x => x.av.Didatica)
            }
  • I do not understand what is "av.Codwsusuario"

  • Oops! Corrected by!

  • Are you using Ajax right? To format the date correctly see this question: http://answall.com/questions/6526

  • OK @André. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.