Consult related tables (Many to Many), grouping results C # Linq Asp.Net MVC


I have a problem.

I have 2 tables (Matricula and ValorAsistencia) that are related to an intermediate table "Assistances" (many to many).

What I want is to make a query that shows me data of the first table, and then a column with the sum of the data of the second related to that first table. Something like this:

In case it helps, the tables in question are the following:

The only thing I could do was:

   var agrupacion = from m in db.matricula
                         join a in db.asistencia on equals a.matriculaid
                         group a by a.matriculaid into grupo                 
 join ma in db.matricula on grupo.firstordefault().matriculaid equals 
                         select new
                         Faltas = grupo.count(), //Solo pude contar la cantidad de Asistencias y lo que necesito es sumar el valor de cada una.
asked by Rodrigo Ramirez 22.11.2018 в 23:42

0 answers