You could probably accomplish in one round trip to the db using Drapper (built on top of Dapper).
Assuming you have a set of SQL queries that return multiple results:
select * from [TableA];
select * from [TableB];
select * from [TableC];
select * from [TableD]
...with each result holding some form of identifier/foreign key to the others, you could probably build up a repository like the one below:
public class Repository : IRepository
{
// IDbCommander is a Drapper construct.
private readonly IDbCommander _commander;
public Repository(IDbCommander commander)
{
_commander = commander;
}
public IEnumerable<A> RetrieveAll()
{
// execute the multiple queries and
// pass control to a mapping function.
return _commander.Query(Map.Results);
}
private static class Map
{
internal static Func<IEnumerable<A>,
IEnumerable<B>,
IEnumerable<C>,
IEnumerable<C>,
IEnumerable<A>> Results = (collectionA, collectionB, collectionC, collectionD) =>
{
// map C and D to B based on their Id's
collectionB.C = collectionC.SingleOrDefault(c => c.Id == b.Id);
collectionB.D = collectionD.SingleOrDefault(d => d.Id == b.Id);
// now map B to A.
collectionA.B = collectionB.Where(b => b.Id == a.Id).ToList();
return collectionA;
}
}
}
Example typed from memory so syntax could be a little off but you get the gist.
I agree with BlackjacetMack that you should rather have some form of pagination in the results (supported in Drapper as well).