I have one customer table and orders table with one-to-many relationship in database and my requirement is to get the corresponding list of orders for each customers.enter image description here
Here is the list of orders done for customerid = 1
I am able to do it by multiple cycle call of database(For example - first i collected the list of customers and then for each customers i collected their orders list in corresponding listDTO and finally returned the list of customer with oders DTO to the BAL Layer.
I think this is not good to call multiple time to call database to get the data. Is there any efficient way of doing it.
Select C.*, O.* FROM Customers C Left Join Orders O on C.CustomerID = O.CustomerID