Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Difficulty getting arrays of associated data in DTOs

$
0
0

I have extracted a database model from an existing database (as code first). I noticed that when I created an api for each table it produced an absolutely insane amount of results. Even when I had about 43 insert lines worth of data it produced I would estimate maybe several tens of millions worth of JSON lines in JSONView (I say estimated because after waiting 2 minutes I had to halt the progress. I tried it in POSTMAN too and it did the same thing!)

I have been using DTOs but I am having difficulty producing a more complex JSON response. At the moment the users of the API have to make multiple calls and combine the data themselves. Maybe that is fine doing it like that but I am not sure if that is inefficient or not.

Does someone have a simple example of how to combine 2 models in a DTO in order to get arrays of data from another table? I tried doing this in the DTO but ended up with the same problem again... millions of results being returned as if were placing the entire copies of the database data inside single array elements! The one from Mike Wasson is a little too simple.


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>