C
C#2y 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
Saber2y ago
don't return the entity, and return a dto that doesn't contain that property if the endpoint doesn't need it?
moritz
moritz2y ago
That's what i am doing already But the field is still in the query string for some reason
Saber
Saber2y ago
well what does the code look like that is retrieving the entity.
moritz
moritz2y ago
It's calling myIqueryable.Select(x => MyDto.FromDb(x)) And the fromdb method maps the entity to the dto
Saber
Saber2y ago
thats probably the issue, EF isn't going to translate that method, it will just call it once it comes back
moritz
moritz2y 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.