C
C#3y ago
moritz

❔ EF core large field slows the entire query down

I have some entities with some large json strings in them. The problem now is that they always get loaded, even if i don't use them. So my endpoint that is just supposed to return some basic information about like 50 objects now takes 300ms on average. Is there a way to mark a property as "not included with normal queries unless specifically requested"?
7 Replies
Saber
Saber3y ago
don't return the entity, and return a dto that doesn't contain that property if the endpoint doesn't need it?
moritz
moritzOP3y ago
That's what i am doing already But the field is still in the query string for some reason
Saber
Saber3y ago
well what does the code look like that is retrieving the entity.
moritz
moritzOP3y ago
It's calling myIqueryable.Select(x => MyDto.FromDb(x)) And the fromdb method maps the entity to the dto
Saber
Saber3y ago
thats probably the issue, EF isn't going to translate that method, it will just call it once it comes back
moritz
moritzOP2y ago
hm well i want to avoid redundancy and i definitely wont map 15 props manually automapper maybe then
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server