I have a ASP.NET Web Api project, and have implemented repository and unitOfWork
pattern.
I currently have a big sql query that I want to implement in code, it includes a lot of tables and joins.
My current solution is just fetching data from repositories one by one, returning an in-memory value or IEnumerable
(not a IQueryable
as it defeats the purpose of repositories) and just joining them later and projecting them to a DTO.
But this makes 20 round trips to the database for 20 tables im using, and its very inefficient.
How can I improve performance (mainly focused on lowering number of round trips to database) by following repository pattern?