Last active
June 9, 2019 23:36
-
-
Save jfbueno/8d6c489f4be010f53e3bd08d7af8706b to your computer and use it in GitHub Desktop.
This file contains 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 class EventosRepository | |
{ | |
public Evento[] ObterEventos() | |
{ | |
var eventos = Connection.Query<Evento>("Select * From Eventos Limit X, Y"); | |
ComporRelacionados(eventos); | |
return eventos; | |
} | |
private void ComporRelacionados(Evento[] eventos) | |
{ | |
var ids = eventos.Map(ev => ev.Id); | |
Dictionary<int, Convidado> convidados | |
= Connection.Query<Convidado>("Select IdEvento, * From Convidados Where EventoId In @ids", new { ids }); | |
foreach(var evento in eventos) | |
evento.Convidados = convidados[evento.Id]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment