1

Object hierarchy may be like Customers and Orders, and I want all customers with orders as List property. Typically, in ado.net, we loop through each customer and load their orders which might result it N number of DB hits with N customers. So, is there are any way to achieve this directly in Dapper, if not, is there better way to achieve this.

Edit

I've idea of retrieving all records at once using join but customers get duplicated. And again, I need to construct the required object from resultant DTO. But I don't know if it is best possible way or there may be any other approach which I might be missing esp. w.r.t Dapper.

Sunny
  • 4,765
  • 5
  • 37
  • 72

1 Answers1

0

You can write a query joining customer and order tables. That will reduce the no of calls to DB but it will increase the amount of duplicate data you fetch from db. But that depends on the number of columns that you fetch from customer table.

Rakhitha
  • 328
  • 2
  • 11