I have a scenario where I am working with a database that consists of two tables linked by a foreign key relationship, following the classic master-detail structure.
My goal is to retrieve all the data from these tables using ASP.NET MVC WebAPI calls from a JavaScript application (specifically an Angular app) running in the browser. Once retrieved, I intend to organize this data into objects that maintain the necessary relationships between detail and master records.
I'm wondering what would be the most efficient and elegant approach to achieve this?
One potential solution is to fetch data from the REST API for the master table, then loop through the results and make additional API calls for each master record to retrieve its related detail records. However, this method can feel somewhat brute-force and will result in a high volume of REST API requests.
Is there a way to design a WebAPI call that simplifies the process of deserializing the data into the correct object structure within the JavaScript environment? One that adheres to RESTful principles and streamlines the retrieval of both master and detail records together?