Created
March 14, 2017 17:51
-
-
Save wescleymatos/92da8694e3c53e6b8729f56f566984ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IQueryable<AlunoDto> BuscarTodosAlunoDtos() | |
{ | |
var alunos = ( | |
from al in _context.Alunos | |
join pe in _context.Pessoas on al.Id equals pe.Id | |
into alu | |
from alun in alu.DefaultIfEmpty() | |
join at in _context.AlunoTurmas on al.Id equals at.AlunoId into alt | |
from ats in alt.DefaultIfEmpty() | |
join tu in _context.Turmas on ats.TurmaId equals tu.Id into tur | |
from turm in tur.DefaultIfEmpty() | |
join se in _context.Series on turm.SerieId equals se.Id | |
into ser | |
from seri in ser.DefaultIfEmpty() | |
join cur in _context.Cursos on seri.CursoId equals cur.Id | |
into cu | |
from cur in cu.DefaultIfEmpty() | |
select new AlunoDto() | |
{ | |
Id = al.Id, | |
DataNascimento = al.Pessoa.DataNascimento, | |
Matricula = al.Matricula, | |
Curso = cur, | |
Serie = seri, | |
Pessoa = alun, | |
Turma = turm | |
} | |
).GroupBy(c => c.Id, (key, c) => c.FirstOrDefault()).AsNoTracking(); | |
return alunos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment