Skip to content

Instantly share code, notes, and snippets.

@jfbueno
Last active June 9, 2019 23:36
Show Gist options
  • Save jfbueno/8d6c489f4be010f53e3bd08d7af8706b to your computer and use it in GitHub Desktop.
Save jfbueno/8d6c489f4be010f53e3bd08d7af8706b to your computer and use it in GitHub Desktop.
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